关于SqlDataAdapter.RowUpdating事件的问题 [英] Question about SqlDataAdapter.RowUpdating Event

查看:52
本文介绍了关于SqlDataAdapter.RowUpdating事件的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在开发一个WebService项目。我正在尝试验证数据,然后通过处理一个

SqlDataAdapter的RowUpdating事件将
更新到数据库。


正在处理的数据具有DataRelation,它与另一个

DataTable相关。至于那个,我还需要从正在更新的

当前行中检索DataRelation。我写了一个看起来像这样的代码,

昏暗关系As DataRelation

For e.Row.Table.ChildRelations中的每个关系

Dim行作为DataRow()


''e.Row.GetChildRows(关系)将始终不返回

rows = e.Row.GetChildRows(relation)

下一页


如果您尝试此代码,即使DataTable,e.Row.GetChildRows(关系)将始终返回

其中包含DataRow

DataRelation。


除此之外,e.Row.HasErrors和e.Row.RowError属性也将是

什么都不返回。


这是.NET Framework 1.1中的一个错误,还是我需要更改编码。


谢谢。

Hi,

I''m working on a WebService project. I''m trying to validate data before they
are updated to the database by handling the RowUpdating event for a
SqlDataAdapter.

The data being handled has DataRelation which is related to another
DataTable. As for that, I also need to retrieve the DataRelation from the
current row being updated. I wrote a code which look something like this,
Dim relation As DataRelation
For Each relation In e.Row.Table.ChildRelations
Dim rows As DataRow()

'' e.Row.GetChildRows(relation) will always return nothing
rows = e.Row.GetChildRows(relation)
Next

If you try this code, e.Row.GetChildRows(relation) will always return
nothing even though the DataTable which contains the DataRow has
DataRelation.

Beside that, the e.Row.HasErrors and e.Row.RowError properties will also
return nothing.

Is this a bug in .NET Framework 1.1 or I need to change the coding.

Thanks.

推荐答案

" Programatix" < PR ********* @ nospam.com> schrieb
"Programatix" <pr*********@nospam.com> schrieb
新闻组:



microsoft.public.dotnet.framework,microsoft.public .dotnet.framework.adonet,m

icrosoft.public.dotnet.framework.webservices,micro soft.public.dotnet.general

,microsoft.public.dotnet.languages.vb

每当制作交叉柱时,请使用*仅*适当的组。这个

与VB.Net无关。


Armin


microsoft.public.dotnet.framework,microsoft.public .dotnet.framework.adonet,m
icrosoft.public.dotnet.framework.webservices,micro soft.public.dotnet.general
,microsoft.public.dotnet.languages.vb
Whenever making crossposts, please use *only* the appropriate groups. This
is not related to VB.Net.

Armin


I终于找到了问题所在。实际上这是我的错。当我告诉
要求SqlDataAdapter更新到数据库时,我使用了以下

重载的Update方法,

重载公共函数更新(DataTable)As整数


因此,DataSet中包含的信息不包含在RowUpdating事件的
中。


使用DataTable而不是DataSet的最初想法是因为在我的
意见中,发送DataTable会比DataSet快,但似乎比b
产生更多的问题我曾经想过。


叹息......


感谢您的阅读。


" ; Programatix" < PR ********* @ nospam.com>在消息中写道

news:eK ************** @ TK2MSFTNGP10.phx.gbl ...
I''ve finally found where the problem lies. It''s my fault actually. When I
asked the SqlDataAdapter to update to database, I used the following
overloaded Update method,
Overloads Public Function Update(DataTable) As Integer

Because of this, the information included in the DataSet is not included in
the RowUpdating event.

The original idea to use DataTable instead of DataSet is because in my
opinion, sending the DataTable will be faster than DataSet, but it seems to
produce more problem than I have ever thought of.

Sigh...

Thanks for reading.

"Programatix" <pr*********@nospam.com> wrote in message
news:eK**************@TK2MSFTNGP10.phx.gbl...

我正在开发一个WebService项目。我正在尝试在
之前验证数据,通过处理SqlDataAdapter的RowUpdating事件将它们更新到数据库。

正在处理的数据具有与之相关的DataRelation另一个
DataTable。至于那个,我还需要从正在更新的当前行中检索DataRelation。我写了一个看起来像这样的代码,
Dim relation As DataRelation
For each.Eow.Table.ChildRelations
Dim rows As DataRow()

>''e.Row.GetChildRows(关系)总是不返回
rows = e.Row.GetChildRows(关系)
下一页

如果你试试这段代码,e。 Row.GetChildRows(关系)将始终返回
,即使包含DataRow的DataTable具有DataRelation。

除此之外,e.Row.HasErrors和e.Row .RowError属性也将什么也不返回。

这是.NET Framework 1.1中的一个错误,还是我需要更改编码。

谢谢。



为什么它与VB .Net无关?我正在使用VB .Net来编写代码。对于那个,它应该与VB .Net有关。


Armin Zingler < AZ ******* @ freenet.de>在消息中写道

news:u4 ************** @ TK2MSFTNGP10.phx.gbl ...
Why is it not related to VB .Net? I''m using VB .Net to write the code. As
for that, it should be related to VB .Net.

"Armin Zingler" <az*******@freenet.de> wrote in message
news:u4**************@TK2MSFTNGP10.phx.gbl...
" Programatix" < PR ********* @ nospam.com> schrieb
"Programatix" <pr*********@nospam.com> schrieb
新闻组:



microsoft.public.dotnet.framework,microsoft.public .dotnet.framework.adonet,m
icrosoft.public。 dotnet.framework.webservices,micro soft.public.dotnet.general,microsoft.public.dotnet.languages.vb

每当制作交叉标记时,请使用*仅*相应的组。这个与VB.Net无关。

Armin


microsoft.public.dotnet.framework,microsoft.public .dotnet.framework.adonet,m icrosoft.public.dotnet.framework.webservices,micro soft.public.dotnet.general ,microsoft.public.dotnet.languages.vb
Whenever making crossposts, please use *only* the appropriate groups. This
is not related to VB.Net.

Armin



这篇关于关于SqlDataAdapter.RowUpdating事件的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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