All,
I am trying to make a login form for my application and I am having issues with changing the password. Please help me if you can.
Here is what I have tried and failed on:
I have a table that has LoginID, Username, Password
I have written a query in UserLogin Table to gets the old password from DB like this
and one that updates the password once changed.
I have three text boxes on my change password form : OldPassword, NewPasword & ConfirmNewPassword and one Button.
Here is the code in that button:
With this code I am getthing this error:
indexOutOfRange
There is no row at position 0.
What am I Doing wrong? Please help me if you can.
Thank you in advance.
I am trying to make a login form for my application and I am having issues with changing the password. Please help me if you can.
Here is what I have tried and failed on:
I have a table that has LoginID, Username, Password
I have written a query in UserLogin Table to gets the old password from DB like this
Code:
SELECT Username, Password
FROM UserLoginTbl
WHERE (Password = @Param1)Code:
UPDATE UserLoginTbl
SET Password = @Password
WHERE (Username = @Param2)I have three text boxes on my change password form : OldPassword, NewPasword & ConfirmNewPassword and one Button.
Here is the code in that button:
Code:
Private Sub OkBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OkBtn.Click
'' validate the new password
If NewPasswordTxt.Text = "" Then
MsgBox("Please Enter your new password", MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly, "Human Error")
NewPasswordTxt.Focus()
Exit Sub
End If
If NewPasswordTxt.Text <> ConfirmPassTxt.Text Then
MsgBox("The password and Password confirmation entered does not match", MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly, "Human Error")
NewPasswordTxt.Focus()
Exit Sub
End If
' get the original password
Dim TA As New DugsiDBDataSetTableAdapters.UserLoginTblTableAdapter
Dim DB = TA.GetDataByPassword("Admin")
If DugsiDBDataSet.UserLoginTbl.Rows.Count > 0 Then
Dim DBPSW As Integer = DB.Rows(0).Item(2) ----HERE is where I am GETTING my ERROR
If DBPSW <> OldPasswordTxt.Text Then
MsgBox("The old password is incorrect", MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly, "Human Error")
OldPasswordTxt.Focus()
Exit Sub
End If
End If
' everything went well, so we are going to update the password in the db
Dim Rc As Integer = TA.UpdateDBVar(NewPasswordTxt.Text, "Password")
If Rc = 0 Then
MsgBox("Password was not updated", MsgBoxStyle.Critical Or MsgBoxStyle.OkOnly, "Error")
Exit Sub
End If
End SubindexOutOfRange
There is no row at position 0.
What am I Doing wrong? Please help me if you can.
Thank you in advance.