Click here to Skip to main content
15,895,781 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,


I am using two datatable,in which i have merged both tables then used getchanges() and then acceptchanges().But the problem is when there is no changes yet it accept changes and return a rows while it should return a null value.

how to solve this??

my using code is:
C#
dtFromDB = objDB.SelectQuery(strQuery);
                   dtMsg1.Merge(dtFromDB);



                   dtChanges = dtMsg1.GetChanges();
                   dtMsg1.AcceptChanges();
Posted
Comments
Sandeep Mewara 11-May-12 5:25am    
Elaborate:there is no changes yet it accept changes and return a rows.
Further, by no changes you mean : dtMsg1 & dtFromDB have same data?

1 solution

Here is the workaround. You can use HasChanges, before calling Get and Accept Changes as:

C#
if (ds.HasChanges(DataRowState.Modified))
{
  DataTable xdt = ds.Tables[i].GetChanges(DataRowState.Modified);
  if (xdt != null)
  {
    // ... work with the changes
    ds.Tables[i].AcceptChanges();
  }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900