Link to home
Start Free TrialLog in
Avatar of ANAT2403
ANAT2403Flag for Israel

asked on

update datatable in a dataset in ADO.NET 2.0

I have an application in VS2005 winforms C#.
I have a dataset with a datatable. I updated some records in the datatable. (not add just update)
I want to create a collection of these changed records . I would also like to see some examples on this issue.
Thankyou
Anat
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ggkumaresh
ggkumaresh

Hi,

  Try this....


private void UpdateDataSet(DataSet myDataSet){
     if(!myDataSet.HasChanges(DataRowState.Modified))

        return;
   DataSet xDataSet;

//To get modified row only
      xDataSet = myDataSet.GetChanges(DataRowState.Modified);

      if(xDataSet.HasErrors){
      // Insert code to resolve errors.
   }
   myOleDbDataAdapter.Update(xDataSet);
}
 



Avatar of ANAT2403

ASKER

Hi,
It doesnot work.
I have a dataset and a datatable dt1.
I create a new datatable dt2 :  dt2 = new dt1();
I edit and change a record in dt2.
The command   myDataSet.HasChanges(DataRowState.Modified) return false.
Hoe do I do it?
>I edit and change a record in dt2.
how?
     this is how:  
   DataRow dr;
            dr = dt2.Rows.Find(keyIDStr);
            dr.BeginEdit();
            dr["ManufacturerID"] = ChangedValue;
           dr.EndEdit();
Anat
>The command   myDataSet.HasChanges(DataRowState.Modified) return false.
actually, the method HasChanges returns a DataSet, and not a boolean?!
I am looking for command on a datatable or a view about the changes. not command on the dataset.
Anat