我正在尝试更新 MSAccess 中的表,其字段的数据类型为“文本”。但是当我运行代码时,它在 UPDATE 语句中显示 sysntax 错误。这是我的vb代码:
将用户调暗为字符串 调暗密码为字符串 调暗 dtT 为新数据表
Dim cmd As New OleDb.OleDbCommand
user = Me.TextBox1.Text
password = Me.TextBox2.Text
If Not cnn.State = ConnectionState.Open Then
cnn.Open()
End If
Try
Dim daA As New OleDb.OleDbDataAdapter("SELECT *FROM adlogin WHERE password='" & Me.TextBox2.Text & "'", cnn)
' MsgBox("STUDENT SAVED!!", MsgBoxStyle.MsgBoxRight)
daA.Fill(dtT)
Me.DG1.DataSource = dtT
'password = DG1.Item(0, 0).Value
'ss1 = DG1.Item(1, 0).Value
If user = DG1.Item(1, 0).Value And password = DG1.Item(0, 0).Value Then
cmd.Connection = cnn
cmd.CommandText = "UPDATE adlogin SET password ='" & Me.TextBox3.Text & "' WHERE user =" & Me.TextBox1.Text
System.Console.WriteLine(cmd.CommandText)
Dim result = MsgBox("Change Administrator password!!! Are you sure?", MsgBoxStyle.YesNo)
If result = DialogResult.Yes Then
cmd.ExecuteNonQuery()
MsgBox("PassWord Changed", MsgBoxStyle.MsgBoxRight)
Panel1.Hide()
End If
Else
MsgBox("INVALID PASSWORD", MsgBoxStyle.Critical)
End If
cnn.Close()
Catch ex As Exception
MsgBox("INVALID PASSWORD " & ex.Message, MsgBoxStyle.Critical)
End Try