How do I check if a user exists in SQL Database using ASP.Net (VB)?

andyhockey8385

New member
I am using a log in page, where users can log in using their assigned user id and password from the database. I know how to compare the password with the userid to determine if the password exists, but I am not sure how to check if the user is in the database.

So whenever I type in a user that does not exist in the database, I am unable to catch this. Anyone know how to do this, so that I can create a message that says "User does not exist".


Here is the code I have that allows you to check if the password is correct.

Dim dv As DataView
Dim password As String

dv = CType(SqlDataSource2.Select(DataSourceSelectArguments.Empty), DataView)
password = CType(dv.Table.Rows(0)(0), String)

If txtPassword.Text <> password Then
pwordValidator.IsValid = False
Else
Response.Redirect("agreement.aspx")
End If
 
Back
Top