Syntax error in UPDATE statement vb.net in access database
i'm getting an error when i'm trying to update my database
Syntax error in UPDATE statement item:In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user. error code: -2147217900
errors: {System.Data.OleDb.OleDbErrorCollection}
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 As New DataSet 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
End Class
链接地址: http://www.djcxy.com/p/42834.html上一篇: “收到的回复不完整”