cpopham Posted December 23, 2004 Posted December 23, 2004 Okay, I have created my SQL statements for DELETE, INSERT, and UPDATE. I can check to see if my dataset has changes. I would like to loop through the rows of the dataset and depending on the change use the appropriate SQL statement, if not change was made to the datarow then it would go to the next. Does anyone know how to do this? Thanks, Chester Quote ____________________________________________ http://www.pophamcafe.com I am starting a developers section, more tutorials than anything.
Administrators PlausiblyDamp Posted December 23, 2004 Administrators Posted December 23, 2004 You could use the Dataset's GetChanges method to find the appropriate rows, or alternatively a DataView and it's RowStateFilter property would work. If you are using a DataAdapter to populate the dataset you could use the DataAdapter's Update method to push the changes back. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
cpopham Posted December 23, 2004 Author Posted December 23, 2004 I am manually populating the dataset. I had been thinking along those lines so, I could do something like this: Dim dsDeletes As New Dataset dsDeletes = myDataset.GetChanges(DataRowState.Deleted) Now, if that works and gives me a dataset with just deletions. My SQL statement I have set up for deletions looks like this: Dim strSQLDelete as string = "DELETE * FROM myTable WHERE ID = '" & strID & '" How can I loop through the datatable rows and get each ID of the rows to pass to my SQL statement? I know this seems like a hard way fo doing it, but I like to understand and control what is going on with my code. Thans, Chester Quote ____________________________________________ http://www.pophamcafe.com I am starting a developers section, more tutorials than anything.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.