updating datagrid in winforms(Its urgent)


I cannot update changesmade to the rows in the datagrid to the database table. I am using SQL server default database PUBS and table "authors"
I created a new windows application
project and also dragged a sqlAdapter and named it as daPubs mySQL
conneection as PubsConn and myDataSet as dsPubs.
I selected the datasource as the table name: pubs.authors
I choose all the Select/Insert/Delete/Update command
I created two buttons LOAD & UPDATE
on the load button i wote the open Connection and also gave the databindingto the datagrid
I have included the following code:
It does not generate any error but also does not update.I had tried to dothe same earlier but it does not work.Kindly let me know the alternative assoon as possible. I will be very grateful to u.

"private void btnUpdate_Click(object sender, System.EventArgs e)
{MessageBox.Show("DataUpdation Start");
daPubs.Update(dsPubs);
MessageBox.Show("Updation Ends");
}
private void btnLoad_Click(object sender, System.EventArgs e)
{
PubsConn.Open();
daPubs.Fill(dsPubs,"authors");
dataGrid1.SetDataBinding(dsPubs,"authors");
PubsConn.Close();
}

Comments

  • Hi Sayyed

    I think you are missing the table name in the update method of data adapter. Make it like that

    daPubs.Update(dsPubs, "authors");
    dsPubs.AcceptChanges();

    If you still have any problem, mail me in personal on frazrasheed@hotmail.com, I will send you the sample program

    Regards,
    Faraz

    :
    : I cannot update changesmade to the rows in the datagrid to the database table. I am using SQL server default database PUBS and table "authors"
    : I created a new windows application
    : project and also dragged a sqlAdapter and named it as daPubs mySQL
    : conneection as PubsConn and myDataSet as dsPubs.
    : I selected the datasource as the table name: pubs.authors
    : I choose all the Select/Insert/Delete/Update command
    : I created two buttons LOAD & UPDATE
    : on the load button i wote the open Connection and also gave the databindingto the datagrid
    : I have included the following code:
    : It does not generate any error but also does not update.I had tried to dothe same earlier but it does not work.Kindly let me know the alternative assoon as possible. I will be very grateful to u.
    :
    : "private void btnUpdate_Click(object sender, System.EventArgs e)
    : {MessageBox.Show("DataUpdation Start");
    : daPubs.Update(dsPubs);
    : MessageBox.Show("Updation Ends");
    : }
    : private void btnLoad_Click(object sender, System.EventArgs e)
    : {
    : PubsConn.Open();
    : daPubs.Fill(dsPubs,"authors");
    : dataGrid1.SetDataBinding(dsPubs,"authors");
    : PubsConn.Close();
    : }
    :
    :

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion