How to find the invalid username?

JCel

Active member
Joined
Jun 15, 2009
Messages
30
Programming Experience
Beginner
Hi here how to inform that the user has entered wrong username/invalid

username...

The scenerio is:

userId=txtUser.text
userPwd=txtPwd.text

If myReader.HasRows Then
Do While myReader.Read
If userId = myReader(0) then
if userPwd = myReader(1) Then
Messagebox.show("Welcome")'here it enters if both username & password

is valid
else
Messagebox.show("Wrong password")'here username is correct,but pwd is

not valid

End If
End if
Loop
End if

'Now what in case of invalid username?
 
What do you mean what to do in case of a wrong username/password? Do nothing, inform the user that he entered the wrong details and leave him with the login-form alone. ;)

Bobby
 
Hi all,

The actual scenerio is:

userId=txtUser.text
userPwd=txtPwd.text

If myReader.HasRows Then
Do While myReader.Read
If userId = myReader(0) then
if userPwd = myReader(1) Then
Messagebox.show("Welcome")'here it enters if both username & password

is valid
else
Messagebox.show("Wrong password")'here username is correct,but pwd is

not valid

End If
'Now i want to tell the user that he has entered wrong username... I tried else here but it displays the messagebox dialog as many times the records found in the DB... Eg. if i have 6 records messagebox is displaying for 6 times... its bcoz the else is inside the loop.. so plz tell me how to do it?
End if
Loop
End if
 
We can't tell you the solution, since we know nothing about your Database-Backend...especially what database it is. But you could execute a scalar command using the following query (which should apply to al SQL-Databases...I hope)

VB.NET:
SELECT COUNT(*) FROM users WHERE username = 'username' AND password = 'password'

If the scalar returns 0, username of password is invalid, if it returns 1, then it's valid.

Bobby
 
Back
Top