Typed DataSet GetChanges Always Nothing?

I have a strong-typed dataset1 and bindingsource1 bound to several textboxes. don't understand why the Getchanges() method always returns nothing, messagebox (below) never opens. I know there is data in the dataset1, just dtChanges is empty?

Q. What am I doing wrong?


bindingSource1.DataSource = dataSet1.DataTable1;

void Save()
{
    bindingSource1.EndEdit();

    DataTable dtChanges = dataSet1.DataTable1.GetChanges();

    MessageBox.Show("Row Count=" + dtChanges.Rows.Count.ToString());
}
pointemanAsked:
Who is Participating?
 
pointemanConnect With a Mentor Author Commented:
Changing any textbox or checkbox data should be a change in the datatable bound to the bindingsource. However, It's not captured as so. Upon further reading I'm finding that datasets are comprised of more than meets the eye which makes sence for Compare reasons. I have yet to try the example below, probably give it go on Monday...

------------------------------

http://social.msdn.microsoft.com/forums/en-US/winformsdatacontrols/thread/8334a2f0-ceaf-4183-bf2d-421556d44914/

Data in a DataRow has several different versions. First, there's the original version. Then, when it's being edited, it has a Proposed version and once it's done being edited, that becomes the Current version. Sometimes when editing, the row is left in the Proposed state and the Edit needs to be ended programmatically.

Here's a method I *always* call before I attempt to check for .HasChanges() before saving data:


protected virtual void CommitProposedChanges(DataSet ds)   
{   
    if (ds == null)   
        return;   
  
    for (int nTable = 0; nTable < ds.Tables.Count; nTable++)   
    {   
        for (int nRow = 0; nRow < ds.Tables[nTable].Rows.Count; nRow++)   
        {   
            if (ds.Tables[nTable].Rows[nRow].HasVersion(DataRowVersion.Proposed))   
            {   
                ds.Tables[nTable].Rows[nRow].EndEdit();   
            }   
        }   
    }   
}   
  

Open in new window

0
 
nishant joshiTechnology Development ConsultantCommented:
can you expalin more about what you want to get changes in binding source or in datatable?
0
 
pointemanAuthor Commented:
Yea! Works Perfectly!
0
 
pointemanAuthor Commented:
I found an excellent link which solves the problem...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.