数据表选择 [英] Data Table Selecting

查看:46
本文介绍了数据表选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我有以下场景:


受保护的子DelRows()

Dim rw As DataRow

Dim rrw作为DataRow

Dim DT as DataTable

Dim rws()as DataRow


对于ds.Tables中的每个rw("表1)。行

rws = ds.Tables(" Table2")。选择(" KeyRow =''"&

rw.Item(0 ).ToString&"''")

每个rrw in rws

rrw.Delete()

下一个

下一页


结束子


如您所见,我的DataSet中有2个DataTable。我必须从Table2中删除数据

,该数据的键是Table1中的Item(0)。现在,我是b / b
认为这将删除我从表2中选择的表格,而不是表格2,但这不是什么工作...... 。

帮助......


Sueffel

---

外发邮件经过认证的无病毒。

由AVG反病毒系统检查( http: //www.grisoft.com)

版本:6.0.558 /病毒库:350 - 发布日期:1/2/2004

Okay, I have the following scenerio:

Protected Sub DelRows()
Dim rw As DataRow
Dim rrw As DataRow
Dim DT as DataTable
Dim rws() as DataRow

For each rw in ds.Tables("Table1").Rows
rws = ds.Tables("Table2").Select("KeyRow = ''" &
rw.Item(0).ToString & "''")
For Each rrw in rws
rrw.Delete()
Next
Next

End Sub

As you can see, I have 2 DataTables in my DataSet. I have to delete data
from Table2, and the key for that data is Item(0) in Table1. Now, I''m
thinking that this will delete the tables I selected out of Table2 from
Table2, but that''s not what''s working...
Help......

Sueffel
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.558 / Virus Database: 350 - Release Date: 1/2/2004

推荐答案

嗨Sueffel,
Hi Sueffel,
rws = ds.Tables(" Table2")。选择(" KeyRow =''"&
rws = ds.Tables("Table2").Select("KeyRow = ''" &




KeyRow是表2中的真实列名吗?

如果是这样,在KeyRow上的table2中使用硬值测试一次,你知道并调试它。


Cor



Is "KeyRow" a real column name in table2?
If so test it once with a hard value in table2 on that KeyRow, that you
know, and debug it.

Cor




" Cor"< no*@non.com>写在留言

新闻:uY ************** @ TK2MSFTNGP09.phx.gbl ...

"Cor" <no*@non.com> wrote in message
news:uY**************@TK2MSFTNGP09.phx.gbl...
嗨Sueffel,
Hi Sueffel,
rws = ds.Tables(" Table2")。选择(" KeyRow =''" &
rws = ds.Tables("Table2").Select("KeyRow = ''" &



是KeyRow table2中的一个真正的列名?
如果是这样,在KeyRow上的table2中使用硬值测试一次,你知道并调试它。

Cor



KeyRow只是我扔出的名字,列的实际名称是

PaymentID,它是PrimaryKey列。如果我这样做:

Dim T as String = rrw.Item(0).ToString,我得到了值。 rrws正确返回

长度。我现在难以理解它为什么不删除。作为一个

" visual"事情,我绑定了一个DataGrid,并将CaptionText设置为表的行数

,并且那些不会改变,但它确实击中了

删除方法。嗯...再次..


Sueffel

---

邮件已通过无病毒验证。

由AVG反病毒系统检查( http://www.grisoft.com)

版本:6.0.558 /病毒库:350 - 发布日期:1/2/2004


KeyRow is just a name I threw out, the actual name of the column is
PaymentID, which is the PrimaryKey column. If I do this:
Dim T as String = rrw.Item(0).ToString, I get the value back. rrws return
sthe length correctly. I am now stumped on why it is not deleting. As a
"visual" thing, i bound a DataGrid to it and set the CaptionText to be the
count of rows for the table, and those don''tchange, but it does hit the
delete method. Hmmm again..

Sueffel
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.558 / Virus Database: 350 - Release Date: 1/2/2004




Cor < no*@non.com>在消息中写道

新闻:uY ************** @ TK2MSFTNGP09.phx.gbl ...

"Cor" <no*@non.com> wrote in message
news:uY**************@TK2MSFTNGP09.phx.gbl...
嗨Sueffel,
Hi Sueffel,
rws = ds.Tables(" Table2")。选择(" KeyRow =''"&
rws = ds.Tables("Table2").Select("KeyRow = ''" &



是KeyRow table2中的一个真正的列名?
如果是这样,在KeyRow上的table2中使用硬值测试一次,你知道并调试它。

Cor



Is "KeyRow" a real column name in table2?
If so test it once with a hard value in table2 on that KeyRow, that you
know, and debug it.

Cor



作为一个添加的WTF,我逐步完成了代码并观看了rowstate,并且它确实切换到了已删除,但是我很担心如果实际上没有引用

返回基表作为删除.....


Sueffel

- -

外发邮件经过认证无病毒。

由AVG反病毒系统检查( http://www.grisoft.com)

版本:6.0.558 /病毒库:350 - 发布日期:1/2 / 2004


As an added WTF, I stepped through the code and watched the rowstate, and it
did switch to Deleted, but I''m concerned that if isn''t actually referencing
back to the base table as deleted.....

Sueffel
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.558 / Virus Database: 350 - Release Date: 1/2/2004


这篇关于数据表选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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