C# .NET - username and password validation - Asked By muthuraman alexander on 25-Nov-10 05:53 AM

hi

i need the code for username and password validation in c#

 ( by having the username and password in database( SQLSERVER) )

i hav to  fetch the login details from the database  and check them in c#



thanks ,

Muthu..
Rohan Dave replied to muthuraman alexander on 25-Nov-10 05:57 AM
your code looks like below :

objCmd = new SqlCommand("Select * From Users Where UserName=@UserId And Password=@PWD", objCon);
objCmd.Parametes.AddWithValue("@UserId", txtUserId.Text.Trim());
objCmd.Parametes.AddWithValue("@PWD", txtPassword.Text.Trim());

objAdpt = new SqlDataAdapter(objCmd);
objDt = new DataTable();
objAdpt.Fill(objDt);

if(objDt.Rows.Count > 0)
  //user found.valid user
else
  //user not found. invalid user

that's all...
Mitesh Darji replied to muthuraman alexander on 25-Nov-10 06:03 AM
using the form Authentication you can achive your task, so can you please review this URL:http://www.15seconds.com/issue/020220.htm
muthuraman alexander replied to Rohan Dave on 25-Nov-10 06:28 AM
hi,

thank u for ur reply

 but i want to check the username and password with CASE SENSITIVE.

what i hav to do


thanks ,

Muthu.
Rohan Dave replied to muthuraman alexander on 25-Nov-10 06:46 AM
the code will check for case sensitive also.. you don't need to do any thing else... try by it and let me know...