Click here to Skip to main content
15,908,254 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
C#
string connection = System.Configuration.ConfigurationManager.ConnectionStrings["itax"].ConnectionString;
        SqlConnection con = new SqlConnection(connection);
        con.Open();

        SqlCommand cmd = new SqlCommand("SELECT @UserId 'UserId',@userPassword 'userPassword' FROM Userlogin WHERE UserId = @UserId", con);
        cmd.Parameters.Add("@UserId", SqlDbType.VarChar, 50).Value = lbl_Employee_code.Text;
        cmd.Parameters.Add("@userPassword", SqlDbType.VarChar, 50).Value = lbl_employee_name.Text;
        cmd.ExecuteNonQuery();
        con.Close();
Posted
Updated 15-May-12 0:12am
v2

You need to store your query-result to a data-reader and in your UI you can assign it to a label

Here is a sample[^]

Regards
Sebastian
 
Share this answer
 
v2
Comments
2011999 15-May-12 6:11am    
yes
Use
ExecuteQuery(); that returns SqlDataReader instead of
cmd.ExecuteNonQuery();.


C#
SqlDataReader  dr=cmd.ExecuteQuery();
if(dr.Read())
{
Label1.Text=dr["UserId"].ToString();
}
 
Share this answer
 

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