i want to know for the label program

Posted by Subhadip under C# on 1/8/2011 | Points: 10 | Views : 1137 | Status : [Member] | Replies : 1
i have added some recore in to data base now i want to display the record from database onto label .for first,last,previous,next using button what should be the code??????? how to bind the label??
name,age,sex,address




Responses

Posted by: Karthikanbarasan on: 1/8/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Hi,

After getting the datas from the database to the dataset apply it to the label as below


private void Form1_Load(object sender, System.EventArgs e) {

string connString = "server=(local)\\SQLEXPRESS;database=MyDatabase;Integrated Security=SSPI";

string SQL = @"select * from employee";

SqlConnection Conn = new SqlConnection(connString);
SqlDataAdapter da = new SqlDataAdapter(SQL, Conn);

da.Fill(dataSet1, "employee");

// Bind the Label's Text property to the ProductID of the Products table
label1.DataBindings.Add("Text", dataSet1, "employee.ID");
// Bind the second label's Text property to the UnitPrice column
label2.DataBindings.Add("Text", dataSet1, "employee.firstname");
}


Thanks
Karthik
www.f5Debug.net

Subhadip, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response