-1

I am doing assignments from campus to make payroll program and my assignment is now 90% almost done. But I encountered a problem when making a password replacement form, I have tried various methods, but they didn't work. I'm use microsoft access database (mdb).

Sorry if my English is bad. Please help.

This is my coding :

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
Gustav
  • 53,498
  • 7
  • 29
  • 55
  • What is a question? – Ilya Mashin Aug 20 '20 at 15:05
  • Don't use MS Access database as backend (e.g x86/x64 driver issues), use SQLite if you need a filebased database! Read on [Bobby Tables](https://bobby-tables.com/) why concating sql statements without sanitizing inputs is dangerous! And read about [How to really store a password in a database](https://bornsql.ca/blog/how-to-really-store-a-password-in-a-database/) and https://stackoverflow.com/questions/1054022/best-way-to-store-password-in-database?noredirect=1&lq=1 – ComputerVersteher Aug 20 '20 at 21:38

1 Answers1

0

You trouble is most likely caused by the fact, that password is a reserverd word in Access. Thus, try to apply brackets:

SqlCMD.CommandText = "update Pengguna set [Password] = '" & TextBox2.Text & "' where Kode_Pengguna = '" & Label4.Text & "'"
        
Gustav
  • 53,498
  • 7
  • 29
  • 55
  • 1
    I think you are correct. https://support.microsoft.com/en-us/office/learn-about-access-reserved-words-and-symbols-ae9d9ada-3255-4b12-91a9-f855bdd9c5a2#:~:text=%22Reserved%20words%22%20are%20words%20and,when%20referring%20to%20the%20field. – Mary Aug 20 '20 at 15:38