I currently have a form where you can enter a username
and password
and it creates a record of it in access. From there, whenever it asks for a username
and password
, you enter yours and it checks to see if it is correct. I have all of this working correctly but now I have a separate form where you can change you password
but I don't know how I would do that. Here is what I have so far:
Dim con As OleDbConnection = New OleDbConnection()
Dim cmd As OleDbCommand
Dim sql = "SELECT UN, PW FROM Users WHERE UN='" & cmbUser.Text & "' AND PW='" & txtOldPass.Text & "'"
cmd = New OleDbCommand(sql, con)
con.ConnectionString = ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=../Database.mdb")
con.Open()
Dim dr As OleDbDataReader = cmd.ExecuteReader
Try
If dr.Read = False Then
MsgBox("Password is incorrect!")
txtOldPass.Text = ""
txtNewPass.Text = ""
txtNewPassConf.Text = ""
ElseIf txtNewPass.Text <> txtNewPassConf.Text Then
MsgBox("Passwords do not match!")
txtOldPass.Text = ""
txtNewPass.Text = ""
txtNewPassConf.Text = ""
Else
'This is where the change password code goes
MsgBox("You password has been changed!")
cmbUser.SelectedIndex = -1
txtOldPass.Text = ""
txtNewPass.Text = ""
txtNewPassConf.Text = ""
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
con.Close()
As you can see, everything seems to be working just fine. Just need code to change the value of the PW cell. I think I could use the sql
string but I am not sure exactly how. Thanks in advance!