Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

____________________________________________

http://www.pophamcafe.com

I am starting a developers section, more tutorials than anything.

  • Administrators
Posted

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.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

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

____________________________________________

http://www.pophamcafe.com

I am starting a developers section, more tutorials than anything.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...