我在尝试更新数据库时遇到错误
UPDATE语句中的语法错误 item:为了评估索引属性,必须对该属性进行限定,并且必须由用户显式提供参数。 错误代码:-2147217900
Imports System.Data.OleDb
Public Class Ubah_Password Dim kns As New OleDbConnection(“provider = microsoft.ace.oledb.15.0; data source =”& Application.StartupPath&“\ database.accdb”) Dim da As New OleDbDataAdapter Dim ds作为新数据集 Dim sql As String
Sub tampilkan() 'menampilkan semua user
ds.Clear()
sql = "SELECT * FROM USERLIST"
da.SelectCommand = New OleDbCommand(sql, kns)
da.Fill(ds, "USERLIST")
End Sub
Sub cariid() 'mencari id
ds.Clear()
sql = "select * from USERLIST where USERNAME = '" & LOGIN.USERNAME.Text & "'"
da.SelectCommand = New OleDbCommand(sql, kns)
da.Fill(ds, "USERLIST")
End Sub
Sub gantiid() 'mengganti password
sql = "update USERLIST set USERNAME = '" & LOGIN.USERNAME.Text & "', PASSWORD= '" & renew.Text & "' where USERNAME ='" & LOGIN.USERNAME.Text & "'"
kns.Open()
da.UpdateCommand = New OleDbCommand(sql, kns)
da.UpdateCommand.ExecuteNonQuery()
kns.Close()
End Sub
Private Sub Ubah_Password_FormClosed(sender As Object, e As FormClosedEventArgs) Handles Me.FormClosed
MAIN_MENU.Panel1.Visible = True
End Sub
Private Sub Ubah_Password_Load(sender As Object, e As EventArgs) Handles MyBase.Load
tampilkan()
MAIN_MENU.Panel1.Visible = False
End Sub
Private Sub oldpass_TextChanged(sender As Object, e As EventArgs) Handles oldpass.TextChanged
cariid()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
cariid()
If ds.Tables("USERLIST").Rows.Count = 0 Then
MessageBox.Show("You Have Enter Wrong Password", "Warning!")
oldpass.Clear()
newpass.Clear()
renew.Clear()
oldpass.Focus()
ElseIf ds.Tables("USERLIST").Rows.Count = 1 And newpass.Text <> renew.Text Then
MessageBox.Show("New Password And Confirmation Must Be Same!", "Warning!")
newpass.Clear()
renew.Clear()
newpass.Focus()
ElseIf ds.Tables("USERLIST").Rows.Count = 1 And newpass.Text = renew.Text Then
gantiid()
MessageBox.Show("Password Change Is Successful!", "Notice")
Me.Close()
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.Close()
End Sub
结束班