this is the way that i used to fill dataset in the formloader
();
String Query;
DataSet ds;
SqlDataAdapter myadapter;
SqlCommand mycommand;
connInterface conn = new connInterface();//connection class
private void Form1_Load(object sender, EventArgs e)
{
cmbEmpID.DataBindings.Clear();
Query = "select * from dbo.bind_tab b";
mycommand = new SqlCommand(Query, conn.createconnection());
myadapter = new SqlDataAdapter(mycommand);
ds = new DataSet();
myadapter.Fill(ds);
cmbEmpID.DataSource = ds.Tables[0];
cmbEmpID.DisplayMember = "eid";
cmbEmpID.ValueMember = "eid";
}
then after i have binded them into two text boxes like this.. that means according to the change of combo box i can update my data table as i wish
private void cmbEmpID_SelectedValueChanged(object sender, EventArgs e)
{
txbEmpName.DataBindings.Clear();
TxbEmpAge.DataBindings.Clear();
txbEmpName.DataBindings.Add("Text", ds.Tables[0], "empname");
TxbEmpAge.DataBindings.Add("Text", ds.Tables[0], "empage");
}
after doing all changes now i tried to update my ql table using updated datatable using sqlCommandbuilder object and adapter. it has been wriiten inside the update button..
private void btn_Update_Click(object sender, EventArgs e)
{
SqlCommandBuilder cb = new SqlCommandBuilder(myadapter);
myadapter.Update(ds.Tables[0]);
MessageBox.Show("updated");
}
no problem of databinding here.. the problem is when i press update button that will not update my sql datble.. because after presing update buttion i go to sql and execute select statement to check whether it has been updated or not.. but it was not.. but i closed the application and if i run it again it shows that dable has updated.. but i have to close the application and run it again.. pleae help me.. i hop that my question is in detail.. thanx..