Solved

VB.NET Dataset doesn't seem to update actual data source

Posted on 2003-11-21
8
402 Views
Last Modified: 2007-12-19
I have the following code:

objAdapter.Fill(objDataSet)
...
objDataSet.Tables("Table").Rows(Row).BeginEdit()
objDataSet.Tables("Table").Rows(Row).Item("TimeAccumulator") = objDataSet.Tables("Table").Rows(Row).Item("TimeAccumulator") + PingRate
objDataSet.Tables("Table").Rows(Row).EndEdit()
...
objDataSet.AcceptChanges
Dim oCB As OleDbCommandBuilder = New OleDbCommandBuilder(objAdapter)
objAdapter.Update(dsModified)

which runs without any errors, but the data source (i have tried both MS Access 2002 and SQL 2000) does not get updated.

I know that the dataset has my changes in it because I have called the objDataSet.GetXML method and written the XML to the event log and I can see my changes.

What am I missing?

0
Comment
Question by:bradmq
  • 3
  • 2
8 Comments
 
LVL 2

Expert Comment

by:MattWare
ID: 9798684
Where does dsModified come from?  You seem to have updated the objDataSet object - not dsModified.  objDataSet.GetXML shows your changes, but do you see them in dsModified.GetXML since that is what you are passing to the update call?

--M
0
 

Author Comment

by:bradmq
ID: 9799025
Whoops,

I posted code between edits.  The line should actually read

objAdapter.Update(objDataSet)

I had had some code previously that looked like this:

Dim dsModified As New DataSet()
dsModified = objDataSet.GetChanges

then I was calling

objAdapter.Update(dsModified)

This didn't work either so I had simplified it to just passing the dataset to the Update method.

Brad

0
 
LVL 2

Expert Comment

by:MattWare
ID: 9799654
Those are supposed to be parens and not brackets...
0
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.

 
LVL 2

Expert Comment

by:MattWare
ID: 9799658
Ignore that post please...wrong window.
0
 

Author Comment

by:bradmq
ID: 9799740
I figured out the problem:

The Update method on the adapter has to be called before the Acceptchanges method on the dataset!

Seems stupid and counter intuitive but I guess if I needed to rollback, I could call dataset.rejectchanges and call the adapter.update method again.
0
 

Accepted Solution

by:
PashaMod earned 0 total points
ID: 11024063
PAQed, with points refunded (125)

PashaMod
Community Support Moderator
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

Suggested Solutions

Title # Comments Views Activity
SPLUNK REST  API call to Splunk to create and index? 2 100
groovy example issue 10 88
oracle query help 18 99
control image tags in a string ? 12 110
Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

919 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

14 Experts available now in Live!

Get 1:1 Help Now