Updating a SQL table using a dataadapter

Posted on 2007-07-19
Last Modified: 2011-09-20
What am I doing wrong?? I am using a dataadapter, filling a dataset, merging it with a dataset which could have new records in it,  and then trying to update the original SQL table with the new data from the dataset. My dataset is merged correctly but my SQL table never gets the new data. I think I am missing something with the SQLCommandBuilder step.
Thanks for any help!

Dim cb As SqlCommandBuilder
queryString = "select * from Inventory"
dsadapter1 = New SqlDataAdapter(queryString, conSQL.ConnectionString)
x1 = dsadapter1.Fill(dsfull1, "Inventory")
dsfull1.Merge(newdataset.Tables("NewInventory"), True, MissingSchemaAction.Ignore)
*** Note: dsfull1 has all the new records at this point **
cb = New SqlCommandBuilder(dsadapter1)
x1 = dsadapter1.Update(dsfull1, "Inventory")
Question by:pamwestphal
    LVL 39

    Accepted Solution

    i think if you do acceptchanges rowstate is changed to not modified, so you are loosing the actual rowstate and update method will not update the data.
    try commenting the line

    or else before dsadapter1.update check whats the rowstate of each row in your datatable.

    Author Comment

    Thank you! Perfect!

    Featured Post

    Courses: Start Training Online With Pros, Today

    Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

    Join & Write a Comment

    The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    745 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

    16 Experts available now in Live!

    Get 1:1 Help Now