I have two layers, a data layer which gets the results from the database and a UI layer which will show the data in label controls Here is the code of data layer
public class Test_DAL
{
public DataSet getEMP(string name1)
{
string conn = System.IO.File.ReadAllText("Connect.txt");
//string conn="Data Source=.\\sqlexpress;Initial Catalog=pss;Integrated Security=True";
//string conn = ConfigurationManager.ConnectionStrings["constr"].ToString();
SqlConnection dbconn = new SqlConnection(conn);
dbconn.Open();
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = new SqlCommand("select * from pss where Emp_code='"+name1+"'", dbconn);
DataSet ds = new DataSet();
da.Fill(ds);
dbconn.Close();
return ds;
}
}
And it is the code of the UI layer
private void btn_search_Click(object sender, EventArgs e)
{
string empcode=txt_empcode.Text;
Test_DAL obj1= new Test_DAL();
obj1.getEMP(empcode);
//dg.DataSource = obj1.getEMP(empcode).Tables[0];
}
And my question is how to show data on labels
Thanks a lot in advance
Your requirement is not very clear. Just to give you an idea of how you can do is
Note: This is neither the best not the appropriate way of doing things. There isn't any exception handling etc.