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..

>because after presing update buttion i go to sql and execute select statement to check whether it has been updated or not..

Of course Update statement will write changes to the underlying datasource. So, I think no need to execute select statement.

thanx for replying me friend..

but friend i executed my select Query on Sql server 2008.. not the .net side..
my question is why data table change did not reflect to table till i execute the form again..
if you don't mind i can end you my database .bak file and solution..
if u can send me your e-mail..
thank you friend..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.