?
Solved

update datatable in a dataset in ADO.NET 2.0

Posted on 2007-08-06
7
Medium Priority
?
691 Views
Last Modified: 2013-11-05
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
0
Comment
Question by:ANAT2403
  • 3
  • 3
7 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 19643373
check out the Dataset.GetChanges method, which returns a DataSet with only those rows that have changes:
http://support.microsoft.com/kb/313485
0
 
LVL 2

Expert Comment

by:ggkumaresh
ID: 19643539
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);
}
 



0
 

Author Comment

by:ANAT2403
ID: 19643850
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?
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 19643876
>I edit and change a record in dt2.
how?
0
 

Author Comment

by:ANAT2403
ID: 19643898
     this is how:  
   DataRow dr;
            dr = dt2.Rows.Find(keyIDStr);
            dr.BeginEdit();
            dr["ManufacturerID"] = ChangedValue;
           dr.EndEdit();
Anat
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 19643958
>The command   myDataSet.HasChanges(DataRowState.Modified) return false.
actually, the method HasChanges returns a DataSet, and not a boolean?!
0
 

Author Comment

by:ANAT2403
ID: 19644029
I am looking for command on a datatable or a view about the changes. not command on the dataset.
Anat
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Six Sigma Control Plans

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question