国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

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

2024-07-10 12:38:40
字體:
來源:轉載
供稿:網友
數據庫連接
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
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 彭阳县| 怀远县| 乐亭县| 北票市| 平山县| 泸水县| 莱阳市| 离岛区| 稷山县| 邹城市| 呈贡县| 子洲县| 龙胜| 磐石市| 剑阁县| 伊川县| 九寨沟县| 红河县| 湛江市| 伊宁市| 秭归县| 嘉义市| 辽源市| 庄浪县| 扎兰屯市| 上高县| 登封市| 定陶县| 龙南县| 陆川县| 宁波市| 北票市| 雷山县| 元朗区| 荆门市| 镇康县| 库尔勒市| 张家川| 陵川县| 嫩江县| 边坝县|