Update multiple tables with a data-adapter

Hi

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

LVL 1
liversenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Raja Jegan RSQL Server DBA & Architect, EE Solution GuideCommented:
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.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Databases

From novice to tech pro — start learning today.