EMW,
I think I'm going to do the folowing:
Why??
The DataAdapter already does this for you, by constructing a DataAdapter
(SqlDataAdapter, OracleDataAdapter, ODBCDataAdabter, or OleDbDataAdapter)
setting its UpdateCommand, DeleteCommand, InsertCOmmand properties with the
correct SQL Statements, then calling its Update method. The DataAdapter
itself will "get the datarow that has changed, then look up (find) the
match..."
Datasets are not "linked" to a database! The contain a copy of the data in a
database when you call Fill, any changes you make are then copied back to
the Database when you do the Update. With minor effort you can actually use
a DataSet copy copy records from one Database to a second Database.
I really do not see what you need the Dataset2 for! After I used fill on a
dataset, I would simply use that dataset.
Can you better explain what you are using it for?
Hope this helps
Jay
EMW said:
I want to update the SQL database.
Dataset2 is linked to the database with the FILL command, so then I want to
write the changes into that dataset and then do an Update.
I think I'm going to do the folowing:
get the datarow that has changed, then look up (find) the matching datarow
in the linked dataset and then copy the changed cells. After that go to the
next datarow...etc...
It is probably not the fastes way to do it, but it should do the trick. It's
only about 4000 rows to look in...
thanks!.
Eric
"Jay B. Harlow [MVP - Outlook]" <
[email protected]> schreef in bericht
EMW,
Are you wanting to update the database or a second dataset?
Now I want to update dataset2 with the changes in dataset1.
You need to use DataSet.GetChanges following by DataSet.Merge. Note if you
are calling DataSet.AcceptChanges in the mix you will loose your actual
changes...
How can I update to the database after it has been closed and re-opened
again?
Create a DataAdapter with the respective Insert, Update, and Delete Commands
and call DataAdapter.Update with your dataset. Note if you are calling
DataSet.AcceptChanges in the mix you will loose your actual changes...
David Sceppa's book "Microsoft ADO.NET - Core Reference" from MS Press
covers using both of the above methods in detail.
David's book is both a good tutorial on ADO.NET plus a good desk reference
once you know ADO.NET!
Hope this helps
Jay
I have two datasets:
dataset1 is filled with the contents of the database, which is closed
afterwards, and then the dataset is changed.
dataset2 is filled with the contents of the database.
Now I want to update dataset2 with the changes in dataset1.
I've tried : dataset2 = dataset1.copy
but that generates an error.
How can I update to the database after it has been closed and re-opened
again?
rg,
Eric