-3
Imports System.Data
Imports System.Data.OleDb
Public Class frmChangePassword
    Public dbrs As New OleDb.OleDbCommand
    Public Provider As New OleDb.OleDbDataAdapter
    Public dbConn As New OleDb.OleDbConnection

    Private Sub frmChangePassword_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


    End Sub

    Private Sub btnChangePassword_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnChangePassword.Click

        Using cn As New OleDbConnection("PROVIDER=Microsoft.JET.OLEDB.4.0;Data Source = login.mdb"), _
         cmd As New OleDbCommand("UPDATE LogInAdmin SET Password= ? WHERE Username= ? ;", cn)
            cmd.Parameters.AddWithValue("?", txtNewPassword.Text)
            cmd.Parameters.AddWithValue("?", txtUsername.Text)
            cn.Open()
            cmd.ExecuteNonQuery()
            MsgBox("Changed")
            cn.Close()
        End Using
    End Sub
End Class
Mubashar
  • 12,300
  • 11
  • 66
  • 95
Tolits
  • 11
  • 3

1 Answers1

1

The word PASSWORD is a reserved keyword for MS-Access/JET, you need to use square brackets around it

cmd As New OleDbCommand("UPDATE LogInAdmin SET [Password]= ? WHERE Username= ? ;", cn)

However, it is a bad idea to use these reserved keywords, if it is still possible I suggest to change that field name and learn how to store an hash of the password instead of clear text.

Community
  • 1
  • 1
Steve
  • 213,761
  • 22
  • 232
  • 286