Reputation: 2428
I started to use ADO.NET for 3 days and want to make a program that can control if UserID and Password is suited with it's database value or not .The point is that i am confused about control all UserID and Password rows to suitable.Must i control UserId and password one by one with a loop or is there any sql command to make this.Thanx..
Upvotes: 0
Views: 161
Reputation: 62524
BTW, I suggest to do not store password in DataBase in plain text, use simple MD5 helper to store MD5 hash of password and just compare hash instead of password itself
Upvotes: 0
Reputation: 69260
Are you doing this to learn or for production use?
If it is for production use I strongly advice you to look into using the ASP.NET Membership provider instead of building your own security system. It is thoroughly tested and known to be secure.
If it is to learn then you should write a suitable SQL statement. One way to do it efficiently with one query is:
SELECT 1 FROM Users WHERE UserId='GivenUserId' AND Password='GivenPassword'
That will give you one result row back if there is a successful match, or no row back if either user name or password is wrong.
Upvotes: 2