欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

asp.net連接數(shù)據(jù)庫(kù) 增加,修改,刪除,查詢(xún)代碼

 更新時(shí)間:2009年07月13日 21:19:35   作者:  
asp.net連接數(shù)據(jù)庫(kù),實(shí)現(xiàn)增加,修改,刪除,查詢(xún)的四大功能完整代碼。
復(fù)制代碼 代碼如下:

'數(shù)據(jù)庫(kù)連接
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


'數(shù)據(jù)操作執(zhí)行
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
'數(shù)據(jù)更新
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() '關(guān)閉連接
End Try
End Sub

相關(guān)文章

最新評(píng)論