serverUrl = readFromIni(My.Application.Info.DirectoryPath & "/config.dll", "Service Information", "IPAddress")

serverID = readFromIni(My " /> 外国成人直播,色偷偷888欧美精品久久久,国产伊人精品在线

色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

asp.net連接數據庫 增加,修改,刪除,查詢代碼

復制代碼 代碼如下:
'數據庫連接
Public Sub connectionDB()
Try

serverUrl = readFromIni(My.Application.Info.DirectoryPath & "/config.dll", "Service Information", "IPAddress")

serverID = readFromIni(My.Application.Info.DirectoryPath & "/config.dll", "Service Information", "Password")
serverName = readFromIni(My.Application.Info.DirectoryPath & "/config.dll", "Service Information", "userID")
serverDataBase = readFromIni(My.Application.Info.DirectoryPath & "/config.dll", "Service Information", "DataBaseName")
If serverID <> "" Then
connectionSqlString = "server =" + serverUrl + ";Database=" + serverDataBase + ";uid =" + serverName + ";pwd=" + serverID + ";max pool size=500"
Else
connectionSqlString = "server =" & serverUrl & ";integrated security = SSPI ;database = " & serverDataBase & ""
End If
conSql = New SqlConnection(connectionSqlString)
objCommand.Connection = conSql
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub


'數據操作執行
Public Sub getConn(ByVal SqlStr As String, ByVal TableName As String)
Try
objCommand.CommandText = SqlStr
objDataSet.Clear()
objDataAdapter.SelectCommand = objCommand
objDataAdapter.Fill(objDataSet, TableName)
Catch ex As Exception
errNo = 1
MsgBox(ex.Message)
End Try
End Sub
'數據更新
Public Sub updateTable(ByVal StrSql As String)
objCommand.CommandText = StrSql
Try
conSql.Open()
Trans = conSql.BeginTransaction
objCommand.Transaction = Trans
objCommand.ExecuteNonQuery()
Trans.Commit()
Catch ese As Exception
MsgBox(ese.Message)
Trans.Rollback() '如果更新異常則取消所有更新
Finally
conSql.Close() '關閉連接
End Try
End Sub

AspNet技術asp.net連接數據庫 增加,修改,刪除,查詢代碼,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 绥棱县| 通山县| 礼泉县| 肃宁县| 南漳县| 汶川县| 黎平县| 合山市| 乌什县| 贵南县| 新源县| 南靖县| 温宿县| 浑源县| 萨嘎县| 溧阳市| 英德市| 沙坪坝区| 犍为县| 安新县| 长治市| 林甸县| 临颍县| 什邡市| 石景山区| 阳新县| 桦川县| 栾川县| 济宁市| 柳州市| 西丰县| 防城港市| 革吉县| 寿阳县| 德安县| 稷山县| 天祝| 剑川县| 梨树县| 阿勒泰市| 本溪市|