Home > DeveloperSection > Forums > select Query with AND Condition
jacob rasel
jacob rasel

Total Post:88

Posted on    November-27-2014 10:39 PM

 ASP.Net Database 

 1 Reply(s)
 467  View(s)
Rate this:

I want to select user but i cant get it . Here's my query


        SqlCommand myCommand = new SqlCommand("Select * from Users where Email=" + UserEmailPass.Email + "And Password=" + UserEmailPass.Password, conn);

        SqlDataReader Detailsreader = myCommand.ExecuteReader();

Is my query correct or not>? please help

Kamlakar Singh
Kamlakar Singh

Total Post:194

Posted on    November-28-2014 7:04 AM

SqlCommand myCommand = new SqlCommand("Select * from Users where Email=@mail and Password@pass" , conn);

System.Data.SqlClient.SqlParameter par = new System.Data.SqlClient.SqlParameter("@mail",  UserEmailPass.Email );

System.Data.SqlClient.SqlParameter par1 = new System.Data.SqlClient.SqlParameter("@pass", UserEmailPass.Password);



        SqlDataReader Detailsreader = myCommand.ExecuteReader();

DO NOT USE string concat!!!!

Don't want to miss updates? Please click the below button!

Follow MindStick