使用AcceptChanges更新数据集时非常慢 [英] very slow when updating dataset using AcceptChanges

查看:127
本文介绍了使用AcceptChanges更新数据集时非常慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用

AcceptChanges更新数据集时是否有人经历过缓慢?


调用此代码时需要花费很多秒才能更新数据库


SqlDataAdapter1.Update(DsStudentCourse1)

DsStudentCourse1.AcceptChanges()


我也想知道因为没有接受AcceptChanges数据仍然保存到数据库中,现在速度更快。


提前感谢任何信息。



使用Update时,执行顺序如下:

1.The DataRow中的值被移动到参数值。

2.引发OnRowUpdating事件。

3.命令执行。

4 。如果命令设置为FirstReturnedRecord,则第一个返回的

结果放在DataRow中。

6.如果有输出参数,则将它们放在DataRow中。

7.The OnR owUpdated事件被提出。

8.AcceptChanges被调用。


所以不需要显式调用AcceptChanges因为Update方法

已经这样做了。

欧内斯特


" jaYPee" <喜****** @ yahoo.com>在消息中写道

news:33 ******************************** @ 4ax.com ...

使用
AcceptChanges更新数据集时是否有人经历过缓慢?

调用此代码时需要花费很多秒才能更新数据库

SqlDataAdapter1.Update(DsStudentCourse1)
DsStudentCourse1.AcceptChanges()

我也在想,因为w / out AcceptChanges数据仍然保存到数据库中它现在更快了。

提前感谢任何信息。



非常感谢您的回复。但是我有这种情况

如果我不使用AcceptChanges数据网格中的记录(

包含相关表格)没有显示


这是场景:


i有一个父/子表单,点击

父表单中的复选框后,程序将执行来自sql

server 2000的存储过程然后将数据保存在相关表中,该表基于来自主表的条件并填充数据网格(

包含相关表格)


但如果我不使用,我点击复选框后无法看到更改

AcceptChanges更新后。


再次感谢任何信息。


周五,2004年6月11日10:21:15 +0200," Ernest Morariu

< er **** @ gesora.com>写道:

来自MSDN:

使用Update时,执行顺序如下:
1. DataRow中的值被移动参数值。
2.引发OnRowUpdating事件。
3.命令执行。
4.如果命令设置为FirstReturnedRecord,则返回第一个
结果放置在DataRow中。
6.如果有输出参数,则将它们放在DataRow中。
7.引发OnRowUpdated事件。
8.AcceptChanges被调用。
所以不需要明确地调用AcceptChanges因为Update方法已经这样做了。

欧内斯特


" JAYPEE" <喜****** @ yahoo.com>在消息中写道
新闻:33 ******************************** @ 4ax.com ..。< blockquote class =post_quotes>使用
AcceptChanges更新数据集时是否有人经历过缓慢?

调用此代码时需要花费很多秒才能更新数据库

SqlDataAdapter1.Update(DsStudentCourse1)
DsStudentCourse1.AcceptChanges()

我也想知道因为没有接受AcceptChanges数据仍然保存到数据库中它现在是更快。

提前感谢任何信息。




嗨jaYPee,

我也见过这个,这是一个奇怪的场景。确认

文档这不应该是必要的,不过它似乎在我的

中看起来与数据源有关而不是数据网格。


昨天Herfried发来了一条关于

arraylist的消息。


Cor

这就是场景:

我有一个父/子表单,在单击
父表单中的复选框后,程序将从中执行存储过程sql
服务器2000然后将数据保存在相关表中,该表基于主表的标准并填充数据网格(其中包含相关表格)
但是如果我在更新后没有使用
AcceptChanges,我点击复选框后就看不到更改了。



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.

解决方案

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.



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.




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.



这篇关于使用AcceptChanges更新数据集时非常慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆