Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Why won't merged dataset update database?

Reply
Thread Tools

Why won't merged dataset update database?

 
 
Mike Hnatt
Guest
Posts: n/a
 
      11-17-2003
I'm baffled. My data store (database) is not updating with a refreshed
dataset.

Here's what is going on:

1) Create a dataset from a table in a database.
2) Create a copy of this dataset and maniuplate (update some records)
3) Now, merge this copied dataset back into the original dataset (using the
Merge method)
4) Now display this original dataset in a datagrid to prove the data has
been updated
5) Now update the database with this modified dataset <<<<DOESN'T HAPPEN

Reason I'm using a copied dataset (for paging stuff to maintain viewstate).

Everything works, and I have bound the modified dataset to a datagrid to
show that indeed the values were updated.
Here is my code: Help! Mike
Dim objDB As New dbconnection
Dim strConn As String = objDB.GetDBConnectionStringWeb
Dim cn As New System.Data.OleDb.OleDbConnection(strConn)
Dim da As New OleDbDataAdapter("SELECT * FROM Summary", cn)
Dim ds As New DataSet
cn.Open()
da.Fill(ds, "Summary")
ds.Merge(myUpdatedDataSet.Summary, False, MissingSchemaAction.Add)
ds.AcceptChanges()
Dim cb As New OleDb.OleDbCommandBuilder(da)
da.UpdateCommand = cb.GetUpdateCommand()
da.Update(ds, "Summary")
DataGrid2.AllowPaging = False
DataGrid2.DataSource = ds
DataGrid2.DataBind()
cn.Close()


 
Reply With Quote
 
 
 
 
Mike Hnatt
Guest
Posts: n/a
 
      11-17-2003
I found out why. Just remove the line "ds.AcceptChanges()". It now works.
Don't ask me why, but it does update the database now.
Mike

"Mike Hnatt" <> wrote in message
news:...
> I'm baffled. My data store (database) is not updating with a refreshed
> dataset.
>
> Here's what is going on:
>
> 1) Create a dataset from a table in a database.
> 2) Create a copy of this dataset and maniuplate (update some records)
> 3) Now, merge this copied dataset back into the original dataset (using

the
> Merge method)
> 4) Now display this original dataset in a datagrid to prove the data has
> been updated
> 5) Now update the database with this modified dataset <<<<DOESN'T HAPPEN
>
> Reason I'm using a copied dataset (for paging stuff to maintain

viewstate).
>
> Everything works, and I have bound the modified dataset to a datagrid to
> show that indeed the values were updated.
> Here is my code: Help! Mike
> Dim objDB As New dbconnection
> Dim strConn As String = objDB.GetDBConnectionStringWeb
> Dim cn As New System.Data.OleDb.OleDbConnection(strConn)
> Dim da As New OleDbDataAdapter("SELECT * FROM Summary", cn)
> Dim ds As New DataSet
> cn.Open()
> da.Fill(ds, "Summary")
> ds.Merge(myUpdatedDataSet.Summary, False, MissingSchemaAction.Add)
> ds.AcceptChanges()
> Dim cb As New OleDb.OleDbCommandBuilder(da)
> da.UpdateCommand = cb.GetUpdateCommand()
> da.Update(ds, "Summary")
> DataGrid2.AllowPaging = False
> DataGrid2.DataSource = ds
> DataGrid2.DataBind()
> cn.Close()
>
>



 
Reply With Quote
 
 
 
 
softsan softsan is offline
Junior Member
Join Date: Jul 2007
Posts: 1
 
      07-24-2007
pls add the following lines of code:
sourceAdapter.AcceptChangesDuringFill = false;
targetAdapter.AcceptChangesDuringFill = false;
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
ASPNETMERGE warning 'Cannot find any assemblies that can be merged' jamesmc ASP .Net 0 03-13-2006 12:26 PM
Javascript two fields merged to one hidden field Microsoft_Public ASP .Net 3 12-14-2005 02:35 PM
Why did G4 get merged with TechTV...? Pope Chuck Computer Support 2 04-23-2005 05:56 PM
JMF: send merged datasource to rtp-target Javier Vazquez Java 4 02-10-2005 05:01 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57