DataReader w/ If Statement
I am working on a login screen, but having issues w/ my iterations. I want someone who is logging in to only have 3 chances before it redirects them to the forgot password page... Below is my code, problem is; it kicks right out of the if statement to the forgot pwd page....
Please help; THANKS
***********************************************
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
Dim Dr As System.Data.SqlClient.SqlDataReader
Dim user, pwd As String
Dim Count As Integer = 0
user = Me.txtUser.Text
pwd = Me.txtPwd.Text
Session("Username") = user
Session("Password") = pwd
SqlConn.Close()
SqlConn.Open()
Dr = SqlComm.ExecuteReader
While Dr.Read
Session("FirstName") = Dr("DTFName").ToString
Session("LastName") = Dr("DTLName").ToString
If Count > 3 Then
If (user = Dr("DTLoginID").ToString And pwd = Dr("DTPassword").ToString) Then
Response.Redirect("Broadcast.aspx")
ElseIf (user <> Dr("DTLoginID").ToString Or pwd <> Dr("DTPassword").ToString) Then
Me.lblError.Text = "Invalid Username/Password; Please Try Again"
Count = Count + 1
'ElseIf (user <> Dr("DTLoginID").ToString And pwd = Dr("DTPassword").ToString) And Count <= 3 Then
' Me.lblError.Text = "Invalid Username/Password; Please Try Again"
' Count = Count + 1
End If
ElseIf Count < 3 Then
Response.Redirect("ForgotPwd.aspx")
End If
lblCount.Text = Count
End While
End Sub
************************************************** ******
THANKS Bunches :D
|