I have a login page, pretty standard, user ID and password. I have my code query the database for a role of '1' (admin role) I know I am putting the id and password in right, but it will not log me in, still returning a false for matching. any clues? my code is below:
strsql = "Select * FROM reg_user"
Dim con As New OleDb.OleDbConnection("Provider=SQLOLEDB; Data Source=localhost; Initial Catalog=webx; User ID=webuser; Password=password")
Dim cmd As New OleDb.OleDbCommand(strsql, con)
Dim reader As OleDb.OleDbDataReader
Dim fullname, cphone As String
If Len(txtuserid.Text) > 4 Or Len(txtpword.Text) > 6 Then
Try
' Open connection to sql database
con.Open()
reader = cmd.ExecuteReader
' Loop through database
While (reader.Read)
If reader("u_name") = struser And reader("u_password") = strpword Then
bvalue = True
fname = reader("u_firstname")
lname = reader("u_Lastname")
cname = reader("u_company")
cemail = reader("u_email")
csubdomain = reader("u_subdomain")
cphone = reader("u_phone")
txtfullname.Text = fname & " " & lname
txtphone.Text = cphone
txtcompany.Text = cname
Else
bvalue = False
End If
End While
' close connection to sql database
'reader.Close()
'displays error message
Catch err As Exception
lblstatus.Text = err.Message
Finally
If (Not con Is Nothing) Then
con.Close()
End If
End Try
If bvalue = True Then
lblstatus.Text = "Logged On!"
Server.Transfer("eventsreg.aspx")
Else
lblstatus.Text = "Check Username and password! If you are not a registered user please register."
End If
Else
lblstatus.Text = "UserID must be atleast 4 characters and passwords must be atleast 6 characters in length."
End If
strsql = "Select * FROM reg_user"
Dim con As New OleDb.OleDbConnection("Provider=SQLOLEDB; Data Source=localhost; Initial Catalog=webx; User ID=webuser; Password=password")
Dim cmd As New OleDb.OleDbCommand(strsql, con)
Dim reader As OleDb.OleDbDataReader
Dim fullname, cphone As String
If Len(txtuserid.Text) > 4 Or Len(txtpword.Text) > 6 Then
Try
' Open connection to sql database
con.Open()
reader = cmd.ExecuteReader
' Loop through database
While (reader.Read)
If reader("u_name") = struser And reader("u_password") = strpword Then
bvalue = True
fname = reader("u_firstname")
lname = reader("u_Lastname")
cname = reader("u_company")
cemail = reader("u_email")
csubdomain = reader("u_subdomain")
cphone = reader("u_phone")
txtfullname.Text = fname & " " & lname
txtphone.Text = cphone
txtcompany.Text = cname
Else
bvalue = False
End If
End While
' close connection to sql database
'reader.Close()
'displays error message
Catch err As Exception
lblstatus.Text = err.Message
Finally
If (Not con Is Nothing) Then
con.Close()
End If
End Try
If bvalue = True Then
lblstatus.Text = "Logged On!"
Server.Transfer("eventsreg.aspx")
Else
lblstatus.Text = "Check Username and password! If you are not a registered user please register."
End If
Else
lblstatus.Text = "UserID must be atleast 4 characters and passwords must be atleast 6 characters in length."
End If