vb.net 如何修改数据库内容?

来源:百度知道 编辑:UC知道 时间:2024/09/26 02:17:47
ACCESS 中的表怎么用VB。NET 修改,比如数据库中有一个tUsers的表,表里面有“id”栏,"pw"栏。要通过已知“ID”栏中的数据,修改“PW”栏中的数据,请问怎么能做到?

Private Function データ修正() As Boolean
Dim strMsg As String = ""
Try
SQL.Length = 0
SQL.AppendLine("update M21_担当者マスタ set")
SQL.AppendLine("パスワード='" & editパスワード.Text & "',")
SQL.AppendLine("where 担当者番号='" & edit社员コード.Text & "'")
strMsg = ExecuteSQLNonQuery(SQL.ToString)
If strMsg <> "" Then
MessageBox.Show(strMsg, "データ修正", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return False
End If
Return True
Catch ex As Exception
MessageBox.Show(ex.Message, "データ修正", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return False
End Try
End Function

Public Function ExecuteSQLNonQuery(ByVal vstrSQL As String) As String
Dim strRet As String = ""
Dim cnn As New SqlClient.SqlConnection(gsConSvr)
Dim cmm As New SqlClient.SqlCommand(vstrSQL