I want to validate username and password i.e.I created a table with two variables username and password in sql. I want to match table username and given username as well as for password. If those matches then only it should login. Please help me with the code sir
anitha10
0
Newbie Poster
Recommended Answers
Jump to PostYou can shorten your SQL to
cmd.CommandText = "SELECT count(*) from UsersTable AS ut WHERE ut.UserName = @UserName AND ut.Password = @Password"
If it's not zero, then you have 1 (or more) users.
Jump to PostAs an aside, you should generally store and check a hash of the password rather than the password itself as this is more secure.
If the answers you have been given helped, please remember to mark this thread as solved :)
All 8 Replies
Rhuntsman21
0
Light Poster
anitha10
0
Newbie Poster
Rhuntsman21
0
Light Poster
Momerath
1,327
Nearly a Senior Poster
Featured Poster
anitha10
0
Newbie Poster
Geekitygeek
480
Nearly a Posting Virtuoso
anitha10
0
Newbie Poster
Geekitygeek
480
Nearly a Posting Virtuoso
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.