By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,011 Members | 2,967 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,011 IT Pros & Developers. It's quick & easy.

very slow when updating dataset using AcceptChanges

P: n/a
does anyone experienced slowness when updating a dataset using
AcceptChanges?

when calling this code it takes many seconds to update the database

SqlDataAdapter1.Update(DsStudentCourse1)
DsStudentCourse1.AcceptChanges()

i'm also wondering because w/ out AcceptChanges the data is still save
into the database and it is now faster.

thanks in advance for any info.
Nov 20 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
From MSDN:

When using Update, the order of execution is as follows:
1.The values in the DataRow are moved to the parameter values.
2.The OnRowUpdating event is raised.
3.The command executes.
4.If the command is set to FirstReturnedRecord, then the first returned
result is placed in the DataRow.
6.If there are output parameters, they are placed in the DataRow.
7.The OnRowUpdated event is raised.
8.AcceptChanges is called.

So don't need to call explicitly AcceptChanges because the Update method
already does this.
Ernest


"jaYPee" <hi******@yahoo.com> wrote in message
news:33********************************@4ax.com...
does anyone experienced slowness when updating a dataset using
AcceptChanges?

when calling this code it takes many seconds to update the database

SqlDataAdapter1.Update(DsStudentCourse1)
DsStudentCourse1.AcceptChanges()

i'm also wondering because w/ out AcceptChanges the data is still save
into the database and it is now faster.

thanks in advance for any info.

Nov 20 '05 #2

P: n/a
Thank you very much for the reply. however i have this scenario that
if i don't use AcceptChanges the record in the datagrid (which
contains related table) is not showing

this is the scenario:

i have a parent/child form that after clicking a checkbox in the
parent form the program will execute the stored procedure from sql
server 2000 then save the data in the related table that is based on
the criteria from the primary table and filling the datagrid (which
contains related table)

but i can't see the changes after clicking the checkbox if i don't use
AcceptChanges after an update.

thanks again for any info.

On Fri, 11 Jun 2004 10:21:15 +0200, "Ernest Morariu"
<er****@gesora.com> wrote:
From MSDN:

When using Update, the order of execution is as follows:
1.The values in the DataRow are moved to the parameter values.
2.The OnRowUpdating event is raised.
3.The command executes.
4.If the command is set to FirstReturnedRecord, then the first returned
result is placed in the DataRow.
6.If there are output parameters, they are placed in the DataRow.
7.The OnRowUpdated event is raised.
8.AcceptChanges is called.

So don't need to call explicitly AcceptChanges because the Update method
already does this.
Ernest


"jaYPee" <hi******@yahoo.com> wrote in message
news:33********************************@4ax.com.. .
does anyone experienced slowness when updating a dataset using
AcceptChanges?

when calling this code it takes many seconds to update the database

SqlDataAdapter1.Update(DsStudentCourse1)
DsStudentCourse1.AcceptChanges()

i'm also wondering because w/ out AcceptChanges the data is still save
into the database and it is now faster.

thanks in advance for any info.


Nov 20 '05 #3

P: n/a
Hi jaYPee,

I have seen this as well, it is a weird scenario. Confirming to the
documentation this should not be necessary, however it is, it seems in my
eyes something with the datasource and not with the datagrid.

There was a kind of the same message from Herfried yesterday about an
arraylist.

Cor

this is the scenario:

i have a parent/child form that after clicking a checkbox in the
parent form the program will execute the stored procedure from sql
server 2000 then save the data in the related table that is based on
the criteria from the primary table and filling the datagrid (which
contains related table)

but i can't see the changes after clicking the checkbox if i don't use
AcceptChanges after an update.

Nov 20 '05 #4

P: n/a
not with the datatable
Nov 20 '05 #5

P: n/a
jayYPee,
Do you have a sample app that identifies this problem.

Are you updating both the Parent & the Child? Are you updating the tables in
the correct order? Are you updating rows in the correct order? (for possible
issues on updating in the correct order see Sceppa's book below).

As Ernest & Cor have stated, calling AcceptChanges after Update should not
be needed, as Update does call AcceptChanges!

You may have stumbled on a bug in the framework (either the dataset or the
datagrid), hence my asking if you have a sample that identifies the problem.
Especially if you can consistently recreate it.

For a good tutorial on ADO.NET as well as a good desk reference once you
know ADO.NET see David Sceppa's book "Microsoft ADO.NET - Core Reference"
from MS press.

Hope this helps
Jay
"jaYPee" <hi******@yahoo.com> wrote in message
news:ov********************************@4ax.com...
Thank you very much for the reply. however i have this scenario that
if i don't use AcceptChanges the record in the datagrid (which
contains related table) is not showing

this is the scenario:

i have a parent/child form that after clicking a checkbox in the
parent form the program will execute the stored procedure from sql
server 2000 then save the data in the related table that is based on
the criteria from the primary table and filling the datagrid (which
contains related table)

but i can't see the changes after clicking the checkbox if i don't use
AcceptChanges after an update.

thanks again for any info.

On Fri, 11 Jun 2004 10:21:15 +0200, "Ernest Morariu"
<er****@gesora.com> wrote:
From MSDN:

When using Update, the order of execution is as follows:
1.The values in the DataRow are moved to the parameter values.
2.The OnRowUpdating event is raised.
3.The command executes.
4.If the command is set to FirstReturnedRecord, then the first returned
result is placed in the DataRow.
6.If there are output parameters, they are placed in the DataRow.
7.The OnRowUpdated event is raised.
8.AcceptChanges is called.

So don't need to call explicitly AcceptChanges because the Update method
already does this.
Ernest


"jaYPee" <hi******@yahoo.com> wrote in message
news:33********************************@4ax.com.. .
does anyone experienced slowness when updating a dataset using
AcceptChanges?

when calling this code it takes many seconds to update the database

SqlDataAdapter1.Update(DsStudentCourse1)
DsStudentCourse1.AcceptChanges()

i'm also wondering because w/ out AcceptChanges the data is still save
into the database and it is now faster.

thanks in advance for any info.

Nov 20 '05 #6

P: n/a
Hi Jay,

I have already made an very simple sample not this problem however it looks
as this and sended it to the ADONET group in a discussion, however the
thread stopped after I had send it.

Are you interested?

Cor
Nov 20 '05 #7

P: n/a
On Fri, 11 Jun 2004 16:02:05 +0200, "Cor Ligthert"
<no**********@planet.nl> wrote:
Hi Jay,

I have already made an very simple sample not this problem however it looks
as this and sended it to the ADONET group in a discussion, however the
thread stopped after I had send it.

Are you interested?

Cor


yes i'm interested
Nov 20 '05 #8

P: n/a
Hi jaYpee,

Whith that sample I show the behaviour that you tell.

(It has to do with the position of a row in a datagrid)

With acceptchanges it is after an insert on the right place, while it is
whithout that at the end.

However for me a kind of same behaviour, as you tell.

(Adding rows in a datagrid and doing an acceptchanges after that is useless
of course, this for the ones who maybe will google this thread onces)

However the sample gives no solution.

Sorry

Cor
Nov 20 '05 #9

P: n/a
Cor,
Can you either post the code or email me it (a linke would work as well). I
don't really have time right now to search the ado group for it.

Thanks
Jay

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:eO**************@TK2MSFTNGP10.phx.gbl...
Hi jaYpee,

Whith that sample I show the behaviour that you tell.

(It has to do with the position of a row in a datagrid)

With acceptchanges it is after an insert on the right place, while it is
whithout that at the end.

However for me a kind of same behaviour, as you tell.

(Adding rows in a datagrid and doing an acceptchanges after that is useless of course, this for the ones who maybe will google this thread onces)

However the sample gives no solution.

Sorry

Cor

Nov 20 '05 #10

P: n/a
Jay,

This is one from the test I did, I also did it with SetDatabinding (when you
want that, it was even smaller, reply than) the result was almost the same
however more difficult to explain.

You see in this sample not the acceptchanges however when that is done with
everything enabled the rows are as well presented in the way as what it in
my opinion should be.

Maybe you find why this behaviour is, I could not find one "logical" clue.

Cor
It needs only a form with a datagrid and this in the loadform event. After
that you have to delete the two ' , to show what I mean.

\\\
Dim ds As New DataSet
Dim dt As New DataTable("Bill")
ds.Tables.Add(dt)
dt.Columns.Add("Ryan")
For i As Integer = i To 3
dt.Rows.Add(dt.NewRow)
dt.Rows.Item(i)(0) = i.ToString
Next
'DataGrid1.DataSource = dt
'with above endabled the datagrid shows 0 1 2 3 4
'DataGrid1.DataSource = Nothing
'now with these two rows disabled it displays 0 1 4 2 3
Dim dr As DataRow = dt.NewRow
dr(0) = "4"
dt.Rows.InsertAt(dr, 2)
DataGrid1.DataSource = dt
///
Nov 20 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.