使用过滤数据循环访问数据 [英] Access data in loop with filtered data

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

问题描述

目前我有一个循环,通过整个表,我想设置为过滤值,但无法使其工作,下面的代码是未过滤的版本

Currently I have a loop that goes thru an entire table that I want to set to a filtered value but can not get it to work, code below is of the unfiltered version

这就是代码的要点所使用的多个字段。

There are more then one field being used by thats the gist of the code.

dim i as integer
for i = 0 to dataset.table.rows.count - 1
try
dim driveletter, drivepath, drivedomain as string
driveletter = Dataset.table.rows(i).Item("Fieldname").Tostring
catch ex as exception
msgbox(ex.tostring)
end try
next


我试过  bindingsource.filter =并且它不起作用,在=我正在过滤掉用户名的驱动器之后有一个值。

I have tried  bindingsource.filter = and it doesnt work, there is a value after the = i am filtering for drives off usernames.

推荐答案

Ryan,

您的代码中存在许多缺陷,但首先,DataSet不是表。这是一堂课。要使用DataSet,您必须使用关键字"New"对其进行实例化。 

There are many flaws in your code, but first, a DataSet is no table. It is a class. To use a DataSet you have to instance it with the keyword "New". 

数据集是一个包装类,它包含DataTables和DataRelations。因此,数据集引用的表总是

A dataset is a wrapper class, which holds DataTables and DataRelations. Therefore a table which is referenced by a dataset is always

MyInstancedDataset.Tables(0).Rows(x).Item(y)

你也可以使用try和catch,但是如果可以抛出错误,只能捕获一些东西。在你的代码中没有什么可以抛出错误。 

Also you use a try and a catch, but there can only be something be catched if an error can be thrown. In your code is nothing which can thrown an error. 

但是让我们提高它的效率。用正常的话说出你的问题是什么。告诉您获取数据表的位置以及如何管理数据表。 

But let us make it more productive. Tell in normal words what your problem is. Tell where you got the datatable and how you managed that to get it. 


这篇关于使用过滤数据循环访问数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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