I have two forms; one for login and another for changing the password.I am using a Microsoft Access database as back-end. I have made the login form using query builder.
The password gets changed, but when I try logging in with the new password it rejects the password. If I close the application and re-open it, the new password works. I want it to get updated right away so that I can use the updated password without having to close the application.
This is the code for changing the password:
Dim conn As New OleDb.OleDbConnection
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=G:\Bus ticketing-5th sem\WindowsApplication3\bus.mdb"
Try
Dim cmd As New OleDbCommand("select [PASSWORD] from login where USERNAME=? ", conn)
If conn.State = ConnectionState.Open Then conn.Close()
conn.Open()
Dim i As Integer
i = MsgBox("Are You Sure Update Selected Record ?", MsgBoxStyle.OkCancel)
If (txtnpass.Text <> txtconpass.Text) Then
MsgBox("Password mismatching")
Else
cmd.CommandText = "UPDATE login SET [PASSWORD]='" & txtnpass.Text & "' WHERE [USERNAME]='" & txtusername.Text & "'"
cmd.ExecuteNonQuery()
''Call busDataSet()
Call Reset()
MsgBox("Record Updated Successfully", MsgBoxStyle.Information)
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
This is the code for the login form using query builder:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim login1 = LoginTableAdapter.UserPasswordString(USERNAMETextBox.Text, PASSWORDTextBox.Text)
If login1 Is Nothing Then
MessageBox.Show(" CHECK USERNAME OR PASSWORD ", "Authentication Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
MsgBox(" WELCOME ADMIN! ", MsgBoxStyle.Information, " SUCCESSFULLY LOGGED IN ")
Form9.Show()
Me.Hide()
End If
End Sub