Dataset.tables [0] .select()出现问题 [英] Issue with Dataset.tables[0].select ()

查看:118
本文介绍了Dataset.tables [0] .select()出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个数据集,其中包含一个带有两列"ID"(int)和"class"(string)的表"ClassName",并且该表中有许多行,当我使用
DataRow [] aRow = dataset.Tables [0] .Select("ID = 2 and class =" second")
对于给定的列值,它没有将行返回到数据行中,并且如果我将select语句更改为Select("ID =" 2和class =" second"),则它返回正确.所以为什么我应该在单引号中提供整数值吗?

请就相同的问题帮助我...

Hi,
i have a dataset which contains a table "ClassName" with 2 columns "ID"(int) and "class"(string) and many rows in the table and when i used
DataRow[] aRow=dataset.Tables[0].Select("ID=2 and class=''second''")
it''s not returning rows into the datarow for given column values and if i change the select statement as Select("ID=''2'' and class=''second''") it"s returning correctly.So why should i provide value in single quotes which is an int.

Please help me regarding the same...

推荐答案

对于给定的列值,如果我更改了select语句,则不会将行返回到数据行中如Select("ID =" 2"and class =" second")一样,它可以正确返回

好吧,这只是意味着并告诉您,在数据集中,所有这些都存储为字符串. ID值可能是整数,但存储为字符串,因此使用引号将整数转换为字符串,并按预期进行过滤.
it''s not returning rows into the datarow for given column values and if i change the select statement as Select("ID=''2'' and class=''second''") it"s returning correctly

Well, this simply means and tells you that in the datatset all of them is stored as a string. ID value might be an integer but is stored as a string and thus using quotes convert the integer to string and filter works as expected.


[添加到Sandeep所说的内容]

首先,其原因很明显.而且,如果要将其视为int,则在数据表中(也可能在数据库表中也相应地)更改类型.
[Adding to what Sandeep said]

First of all, the reason for this is quite obvious. And if you want to treat it as an int, then change the type in your data table (and perhaps correspondingly in your DB table too).


这篇关于Dataset.tables [0] .select()出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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