Re: Issue with loginsystem
The issue is that you are loping through your DataTable and comparing the user input to each row BUT as soon as you find a mismatch you pop up a message and stop looking, which means that you're only ever going to compare the input to the first row.
Your whole validation routine is misguided I'm afraid. I don't know whether you've been told to do it that way or not but you should never tell the user that they have a valid user name but invalid password. That simply makes it easier for those trying to gain unauthorised access. You should simply tell the user that there login passed or failed and never why it failed. As such, what you should be doing is looping through the table until you find a match and, if you get to the end of the table without finding one, you know the login failed.
Re: Issue with loginsystem
Can't he use a where usernane = @username on a Sproc instead of doing a loop on the entire table?
Re: Issue with loginsystem
Quote:
Originally Posted by
sapator
Can't he use a where usernane = @username on a Sproc instead of doing a loop on the entire table?
Absolutely. That is again a more correct way to do things. It depends on what the instructions are but if you want to do it properly then that is the way to go, although whether or not to use a stored procedure is a different argument again. @michel vervoort, for more information on sapator's suggestion, you might like to follow the CodeBank link in my signature and check out my thread on WinForms Login. It sets up the interface and then provides a link to another thread that demonstrates the validation.
Re: Issue with loginsystem
Thanks for your replies and tips i will look into that.