[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Updating a SQL table using a dataadapter

Posted on 2007-07-19
Medium Priority
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

appari earned 2000 total points
ID: 19527949
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

ID: 19528638
Thank you! Perfect!

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

873 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