Updating database

  • Thread starter Thread starter John Shaw
  • Start date Start date
J

John Shaw

I am trying to copy the data from one database table to
another server with the same table by writing a simple
program. For some reason the update does not occur. Can
anyone explain?

sqlDataAdapter1.Fill(dataSet11,"ATable");
sqlDataAdapter2.Fill(dataSet21,"ATable");
dataSet11.Merge(dataSet21,false);
dataSet11.AcceptChanges();
int y = sqlDataAdapter1.Update(dataSet11,"ATable");

y returns = 0
No rows are updated. Is there some other step I need to
add to make the update recognize the rows have changed
and to make the update? The merge seems to work when I
view the datasets -21 and 11 in QuickWatch they appear
to be the same with the same # of rows and data. The
Update command was generated by the DataAdapter
Configuration Wizard.
 
Hi John,

I agree with Miha. AcceptChanges method will set the Current row values to
be the Original values and will set the RowState property to Unchanged.
When you call the Update method, it will check the RowState property to
determine if the row is going to be updated.

Hope this help,

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Back
Top