?
Solved

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

Posted on 2003-11-21
8
Medium Priority
?
407 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
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…
Progress

764 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