• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 435
  • Last Modified:

Update dataset back to database

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
mattphung
Asked:
mattphung
  • 3
  • 3
1 Solution
 
newyuppieCommented:
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
 
ursangelCommented:
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
 
mattphungAuthor Commented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
newyuppieCommented:
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
 
mattphungAuthor Commented:
Is there a good tutorial on this?
Thanks for all your help.
0
 
newyuppieCommented:
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
 
mattphungAuthor Commented:
Thanks for going the extra mile! I really appreciate all your help.
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now