Solved

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

Posted on 2003-11-21
8
404 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
A short article about problems I had with the new location API and permissions in Marshmallow
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

856 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