Click here to Skip to main content
15,846,826 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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...
Posted

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.
 
Share this answer
 
Comments
Nish Nishant 20-Apr-11 10:19am    
Voted 5, proposed as answer.
Sandeep Mewara 20-Apr-11 10:52am    
Thanks again! :)
Nish Nishant 20-Apr-11 10:53am    
You are welcome!
siva455 20-Apr-11 11:51am    
In dataset and database the type is int only
Sandeep Mewara 20-Apr-11 11:59am    
Well, your filter not working simply implies it is not integer in the dataset. Simple!
[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).
 
Share this answer
 
Comments
siva455 20-Apr-11 11:49am    
In dataset and database the type is int only
Nish Nishant 20-Apr-11 11:50am    
How did you verify that?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900