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

Total Post:88

Points:616
Posted on    November-27-2014 10:39 PM

 ASP.Net Database 
Ratings:


 1 Reply(s)
 489  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

Points:1396
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);

       myCommand.Parameters.Add(par);

       myCommand.Parameters.Add(par1);

        SqlDataReader Detailsreader = myCommand.ExecuteReader();

DO NOT USE string concat!!!!


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

Follow MindStick