looping through a dataset

dougancil
06-02-2011, 02:08 PM
I have a dataset that I'm trying to loop through to be able to save any changes made to that dataset and update my database doing so. Is that possible? I've seen that it's possible to do it with datatables but not datasets. If so, can someone offer a starting point for me to learn with?

Thank you

Doug

DrPunk
06-03-2011, 04:02 AM
Yes, it's possible. This article should get you started -> http://support.microsoft.com/kb/301248

It can get quite complicated though. A dataset is offline, so it has to take into account that the data in the database might have changed since it was read into the dataset. Therefore, when using the SqlCommandBuilder to create the Update, Insert and Delete commands, it makes them so that it can only update the lines that are the same as the rows in the dataset (i.e. it adds a where clause for every field). If the data in the table has changed for a row then it won't update it and it's down to you to deal with the problem (which you can do in the RowUpdated of the DataAdapter and look for errors).

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum