View Full Version : login trouble

04-20-2012, 11:50 PM
Hello I am working on my login.aspx page and I am having trouble validating users. I am not getting any errors but the code is always evaluating to
errormessage.Text = "Your email or password is wrong"
End If
eventhough the email and passwords are correct. I also dont know if this is right but i am using the
Membership.ValidateUser(email.Text, password.Text) but using it on a database that i created.

Protected Sub loginbutton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles loginbutton.Click
myconnection = New SqlConnection("Server=localhost\SQLEXPRESS;Database=VoteNow;" &
"Integrated Security=True")
readata = "(SELECT email,password FROM table2 Where email='@email' and password='@password')"
mycommand = New SqlCommand(readata, myconnection)
mycommand.Parameters.AddWithValue("@email", email.Text)
mycommand.Parameters.AddWithValue("@password", password.Text)

If Membership.ValidateUser(email.Text, password.Text) Then
myreader = mycommand.ExecuteReader(CommandBehavior.CloseConnection)
errormessage.Text = "Your email or password is wrong"
End If
End Sub
End Class