Update multiple tables with a data-adapter


I have a dataset composed of data from two tables. I show the dataset in a grid, using a dataadapter. I would like to make the data editable, so I need to write the dataadapters update command myself. But how do I do this, when there's two tables involed?

Best regards
The two example tables looks like this:
Table A
ID - TextA1 - TextA2 - IDB
1     red       blue        - 1
2     green   white      - 2
3     pink       black      - 2
Table B
ID - TextB1 - TextB2
1    House     Car
2    Cat          Dog
DataAdapter from Select * from A, B where A.IDB = B.ID that is later used to populate a Dataset

Open in new window

Who is Participating?
Raja Jegan RConnect With a Mentor SQL Server DBA & ArchitectCommented:
Hope you will be validating what are the list of fields updated in the  dataset and you do UPDATE statements accordingly.

If a column in Table A is being updated , Issue an UPDATE statement on Table A
Or If a column in Table B is being updated , Issue an UPDATE statement on Table B
And if columns in Both tables Table A and Table B are updated, then issue two UDPATE statements.

Either you have to do it this way in T-SQL or you can call a procedure with the updated values so that procedure does the updates accordingly.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.