Click here to Skip to main content
15,894,539 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
cmd.CommandText = "Select Emp_Id,Name,Address,District,Pin,Mobile from emp ('" + lblempid.Text + "','" + lblname.Text + "','" + lbladdres.Text + "','" + lbldist.Text + "','" + lblpin.Text + "','" + lblmob.Text + "' WHERE Email = " + user + ")";
Posted

1 solution

1. Please do not ever do sql like this because you are open to sql injections.
2. You need single quotes around the user.
3. What are you trying to do by passing in the label text inside ()
3. Do something more like this:

C#
cmd.CommandText = "SELCT Emp_Id, Name, Address, District, Pin, Mobile FROM emp WHERE Email = @user"
cmd.Parameters.AddWithValue("@user", user);
 
Share this answer
 
Comments
Harshit Wadhera 25-Jan-15 13:38pm    
I have to display 4 data Column on 4 label.
ZurdoDev 25-Jan-15 16:53pm    
Then use the code I gave you and do something like this:

SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
dr.Read();
lblName = dr["Name"].ToString();
... etc
}
Harshit Wadhera 25-Jan-15 19:23pm    
yeah thanx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900