DataSet - 添加新行 [英] DataSet - adding new row

查看:51
本文介绍了DataSet - 添加新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我填写数据集并且没有数据。仍然创建数据集

,零行(所有列都在那里)。当我使用

添加我的第一行时,下面的脚本需要超过2秒才能添加???如果我添加第二个

行,即时。


如何消除这种延迟?



Dim oRow As DataRow = dsOrder.Tables(" PaymentsAndCredits")。NewRow


oRow(" ENumber")= ENumber

oRow(" ; CNumber")= CNumber

oRow(" PType")=类型

oRow(PAmount)=金额

oRow( TNumber)= 0

oRow(TAdjustment)= 0

oRow(应用)=错误


dsOrder.Tables(" PaymentsAndCredits")。Rows.Add(oRow)

解决方案

Eric Petruzzelli< eg * @ e-globalpartners.com>写道:

如果我填充我的数据集,没有数据。数据集仍然是零行创建的(所有列都在那里)。当我使用下面的脚本添加我的第一行时,需要超过2秒才能添加???如果我添加第二行,即时。

如何消除这种延迟?

Dim oRow As DataRow = dsOrder.Tables(" PaymentsAndCredits") .NewRow

oRow(" ENumber)= ENumber
oRow(CNumber)= CNumber
oRow(PType)= type
oRow (PAmount)=数量
oRow(TNumber)= 0
oRow(TAdjustment)= 0
oRow(Applied)= False
dsOrder.Tables(" PaymentsAndCredits")。Rows.Add(oRow)



尝试在每一行之间倾销DateTime.Now,

这样你就可以看到时间在哪里。


你可能只是看到JITting,但它听起来不太可能,如果它花了2美元b
。这是什么类型的机器?


-

Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet

如果回复小组,请不要给我发邮件


Jon,


它在我的笔记本电脑上运行,什么都没有错在那里。这是唯一一瓶

脖子。 2秒并不夸张。


它出现在线上:


dsorder.Tables(" PaymentsAndCredits")。行。添加(oROw)

仅在第一行发生。我重写了我的SQL插入,删除stmts

以防数据类型发生变化。没什么。


Eric。


Jon Skeet [C#MVP]写道:

Eric Petruzzelli < eg*@e-globalpartners.com>写道:

如果我填写我的数据集,没有数据。数据集仍然是零行创建的(所有列都在那里)。当我使用下面的脚本添加我的第一行时,需要超过2秒才能添加???如果我添加第二行,即时。

如何消除这种延迟?

Dim oRow As DataRow = dsOrder.Tables(" PaymentsAndCredits") .NewRow

oRow(" ENumber)= ENumber
oRow(CNumber)= CNumber
oRow(PType)= type
oRow (PAmount)=数量
oRow(TNumber)= 0
oRow(TAdjustment)= 0
oRow(Applied)= False
dsOrder.Tables(" PaymentsAndCredits")。Rows.Add(oRow)



2秒听起来很长时间。你知道它在哪个部分花时间吗?尝试在每行之间转出DateTime.Now,
这样你就可以看到时间在哪里。

你可能只是看到JITting,但如果它正在采取<听起来不太可能br /> 2秒。这是什么类型的机器?




Eric Petruzzelli< eg*@e-globalpartners.com>写道:

它在我的笔记本电脑上运行,没有错。这是唯一的瓶颈。 2秒并不夸张。

它出现在线上:

dsorder.Tables(" PaymentsAndCredits")。rows.add(oROw)

仅在第一行发生。我重新编写了我的SQL插入,删除stmts
以防数据类型发生变化。什么都没有。




你有很多限制因素检查其他表吗?如果您只是从头开始创建数据集

而不涉及任何地方的数据库,只需添加简单的列?

$

b $ b -

Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet

如果回复小组,请不要给我发邮件


If I fill my dataset and there is no data. The dataset is still created
with zero rows (all columns are there). When I add my first row using
the script below, it takes over 2 seconds to add??? If I add the second
row, instant.

How can I eliminate this delay?


Dim oRow As DataRow = dsOrder.Tables("PaymentsAndCredits").NewRow

oRow("ENumber") = ENumber
oRow("CNumber") = CNumber
oRow("PType") = type
oRow("PAmount") = amount
oRow("TNumber") = 0
oRow("TAdjustment") = 0
oRow("Applied") = False

dsOrder.Tables("PaymentsAndCredits").Rows.Add(oRow )

解决方案

Eric Petruzzelli <eg*@e-globalpartners.com> wrote:

If I fill my dataset and there is no data. The dataset is still created
with zero rows (all columns are there). When I add my first row using
the script below, it takes over 2 seconds to add??? If I add the second
row, instant.

How can I eliminate this delay?

Dim oRow As DataRow = dsOrder.Tables("PaymentsAndCredits").NewRow

oRow("ENumber") = ENumber
oRow("CNumber") = CNumber
oRow("PType") = type
oRow("PAmount") = amount
oRow("TNumber") = 0
oRow("TAdjustment") = 0
oRow("Applied") = False

dsOrder.Tables("PaymentsAndCredits").Rows.Add(oRow )



2 seconds sounds like a very long time. Do you know which part it is
that''s taking the time? Try dumping out DateTime.Now between each line,
so you can see where the time is taken.

You could just be seeing JITting, but it sounds unlikely if it''s taking
2 seconds. What kind of machine is this on?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Jon,

It is running on my laptop, nothing wrong there. This is the only bottle
neck. And 2 seconds is not an exaggeration.

It occurs on the line:

dsorder.Tables("PaymentsAndCredits").rows.add(oROw )
It only happens with the first row. I redid my SQL Insert, Delete stmts
in case there was a dataType change. Nothing.

Eric.

Jon Skeet [C# MVP] wrote:

Eric Petruzzelli <eg*@e-globalpartners.com> wrote:

If I fill my dataset and there is no data. The dataset is still created
with zero rows (all columns are there). When I add my first row using
the script below, it takes over 2 seconds to add??? If I add the second
row, instant.

How can I eliminate this delay?

Dim oRow As DataRow = dsOrder.Tables("PaymentsAndCredits").NewRow

oRow("ENumber") = ENumber
oRow("CNumber") = CNumber
oRow("PType") = type
oRow("PAmount") = amount
oRow("TNumber") = 0
oRow("TAdjustment") = 0
oRow("Applied") = False

dsOrder.Tables("PaymentsAndCredits").Rows.Add(oRow )



2 seconds sounds like a very long time. Do you know which part it is
that''s taking the time? Try dumping out DateTime.Now between each line,
so you can see where the time is taken.

You could just be seeing JITting, but it sounds unlikely if it''s taking
2 seconds. What kind of machine is this on?




Eric Petruzzelli <eg*@e-globalpartners.com> wrote:

It is running on my laptop, nothing wrong there. This is the only bottle
neck. And 2 seconds is not an exaggeration.

It occurs on the line:

dsorder.Tables("PaymentsAndCredits").rows.add(oROw )
It only happens with the first row. I redid my SQL Insert, Delete stmts
in case there was a dataType change. Nothing.



Do you have a lot of constraints involved which check other tables? Do
you get a similar hit if you just create the dataset from scratch
without involving the database anywhere, just adding simple columns?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


这篇关于DataSet - 添加新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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