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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nishant joshiTechnology Development ConsultantCommented:
can you expalin more about what you want to get changes in binding source or in datatable?
0
pointemanAuthor 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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pointemanAuthor Commented:
Yea! Works Perfectly!
0
pointemanAuthor Commented:
I found an excellent link which solves the problem...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.