sqlCeDataAdapter.update, Update requires a valid UpdateCommand when passed DataRow collection with modified rows

603 views Asked by At

**strong text* hi all this is my code :

for(int i =0 ;i<listView1.Items.Count;i++)
        {
            if(listView1.Items[i].Checked)
            {
                DataRow dr = ds.Tables["EXPORT"].Rows[i];
                dr.BeginEdit();
                dr["MODE_PAIEMENT"] = "cheque";
                dr["SOLDE_RESTANT"] = "0";
                dr.EndEdit();
                //dt.AcceptChanges();
                //ds.Merge(dt);
                try
                {
                    connexion.da.Update(ds, "EXPORT");
                }
                catch (Exception x) {
                    MessageBox.Show(x.ToString());
                }

i have that erreur : Update requires a valid UpdateCommand when passed DataRow collection with modified rows. What shoud i do !! !

1

There are 1 answers

0
Cam Bruce On BEST ANSWER

You need to do what it says, and set the UpdateCommand Property of the DataAdapter with your SQL UPDATE statement.

SqlDataAdaptor.UpdateCommand property

SqlCommand updateCmd = new SqlCommand();
updateCmd.CommandText = "UPDATE table SET col=@val";

 connexion.da.UpdateCommand = updateCmd;