如何解决附加信息:UPDATE语句中的语法错误
我正在做校园作业,以制作薪资计划,现在我的作业几乎完成了90%。但是在制作密码替换表单时遇到了一个问题,我尝试了各种方法,但是它们不起作用。我正在使用Microsoft Access数据库(mdb)。
对不起,我的英语不好。请帮忙。
这是我的编码:
Private Sub Button1_Click(sender As Object,e As EventArgs) Handles Button1.Click
Call Koneksi()
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Then
MsgBox("Password masih kosong",vbExclamation + vbOKOnly,"Pesan")
Exit Sub
End If
If TextBox3.Text <> TextBox2.Text Then
MsgBox("Password konfirmasi salah")
TextBox3.Focus()
Else
If MessageBox.Show("Yakin akan ganti Password..?","",MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then
Dim SqlCMD As New OleDbCommand
SqlCMD.Connection = DataBase
SqlCMD.CommandType = CommandType.Text
SqlCMD.CommandText = "UPDATE Pengguna set Password = '" & TextBox2.Text & "' where Kode_Pengguna = '" & Label4.Text & "'"
SqlCMD.ExecuteNonQuery()
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
Me.Close()
Else
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
Me.Close()
End If
End If
End Sub
解决方法
您的麻烦很可能是因为 password 是Access中的保留字。因此,请尝试使用方括号:
SqlCMD.CommandText = "update Pengguna set [Password] = '" & TextBox2.Text & "' where Kode_Pengguna = '" & Label4.Text & "'"
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。