Solved

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

Posted on 2003-11-21
8
401 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

A short article about problems I had with the new location API and permissions in Marshmallow
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
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 …

757 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

13 Experts available now in Live!

Get 1:1 Help Now