Solved

Update dataset back to database

Posted on 2007-12-03
7
398 Views
Last Modified: 2010-04-21
If I have a dataset with 3 tables linked by primary and foreign keys can I insert data into the tables and then use the dataset to update the database?
0
Comment
Question by:mattphung
  • 3
  • 3
7 Comments
 
LVL 13

Expert Comment

by:newyuppie
ID: 20400900
yes sure, you need to use an adapter for that purpose.

MyAdapter.Update(MyDataset)

The connection string to the database is part of the adapter's properties.

Hope it helps,
NY
0
 
LVL 5

Expert Comment

by:ursangel
ID: 20400912
Offcourse you can do it.
you need to have a datasource that will be pointing to this dataset.
Update the dataset and then finally when you have done with the updates, just call the
dataset.ApplyUpdates whihc will update your database.
0
 

Author Comment

by:mattphung
ID: 20430008
Once I update the database with my dataset, will the relationships for each new record be kept? So, the database will assisgn new primary keys to the tables and update all the foreign keys.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 13

Expert Comment

by:newyuppie
ID: 20430705
I beliebe the database primary keys and the dataset primary keys and relationships are separate. You will need to duplicate them in each, or keep them only in the database.

NY
0
 

Author Comment

by:mattphung
ID: 20431764
Is there a good tutorial on this?
Thanks for all your help.
0
 
LVL 13

Accepted Solution

by:
newyuppie earned 500 total points
ID: 20434169
maybe try reading these:

http://asp.dotnetheaven.com/howto/doc/adoplus/UpdateDataFromDB.aspx (will show vb code examples of the basics of retrieving to datatset and updating database)

http://www.dbazine.com/sql/sql-articles/cook4 (also interesting and shows a bit of foreign key stuff)

but the place to start i guess would always have to be MSDN documentation. try reading this and following the links: http://msdn2.microsoft.com/en-us/library/system.data.dataset.aspx

its such a broad subject that its very difficult to direct you to anything in particular. the way i search for stuff is first the MSDN, follow links in there, and for specific things i dont understand there i google them up (for example, google "vb net dataset foreign key"). hope it helps

NY
0
 

Author Closing Comment

by:mattphung
ID: 31412514
Thanks for going the extra mile! I really appreciate all your help.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now