updating datagrid in winforms(Its urgent) - Programmers Heaven

Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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

  • frazrasheedfrazrasheed Posts: 18Member
    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 [email protected], 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.