DataTable.Select problem in ASP.NET 2.0

A

Aryan

Hi,
I am having problem with DataTable.Select() method. I am using
ASP.NET 2.0.
I have DataSet which reads data from XML file using DataSet.ReadXML().
Now this
dataset has various datatable, created by XML file. I am taking one of
the datatable
from this dataset and want to filter on that datatable using Select()
method.
Now here the problem start, like when I pass multiple "And" clause in
this method
it doesnt recognize that parameter and doesnt return the value, where
as it should return the value.
For Example,

DataTable has various rows containing data, now when i try to filter
this data, then
it should return me data for the passed criteria. But to my surprise
its not doing like this.
Although I have that data which I am passing as filter expression in
Select Method(). This
method works for some criteria and it doesnt work for some criteria.

For example: -

dim dt as datatable = ds.Tables("Report")
drow = dt.Select("id = 1 and number=5 and value=10")
//basically this should return me datarow, but its not returning any
datarow and returns 0 as count.
//but the same line of code works for some of the values.

I am not able to figure out what could be the problem, is this a bug
from Microsoft, as it
was there in ASP.NET 1.1.

Please help me out, as i dont want to use DataView.RowFilter property
 
M

Marina Levit [MVP]

I've used the Select method with some pretty complex criteria without
problems. I suspect something else is going on here, like the data isn't
what you think it is, etc.

You should try creating the datatable manually, adding the rows, setting the
values, then call Select on it. Something we can all run, and see if the
row isn't found.
 
V

vMike

Aryan said:
Hi,
I am having problem with DataTable.Select() method. I am using
ASP.NET 2.0.
I have DataSet which reads data from XML file using DataSet.ReadXML().
Now this
dataset has various datatable, created by XML file. I am taking one of
the datatable
from this dataset and want to filter on that datatable using Select()
method.
Now here the problem start, like when I pass multiple "And" clause in
this method
it doesnt recognize that parameter and doesnt return the value, where
as it should return the value.
For Example,

DataTable has various rows containing data, now when i try to filter
this data, then
it should return me data for the passed criteria. But to my surprise
its not doing like this.
Although I have that data which I am passing as filter expression in
Select Method(). This
method works for some criteria and it doesnt work for some criteria.

For example: -

dim dt as datatable = ds.Tables("Report")
drow = dt.Select("id = 1 and number=5 and value=10")
//basically this should return me datarow, but its not returning any
datarow and returns 0 as count.
//but the same line of code works for some of the values.

I am not able to figure out what could be the problem, is this a bug
from Microsoft, as it
was there in ASP.NET 1.1.

Please help me out, as i dont want to use DataView.RowFilter property
The data in your table probably isn't in integer form. Depends on you xml
schema if you have one. If not they are probably all text type. Depending on
how much you are using the data you might also want to look into serializing
your xml and putting the data into a class that inherits the arraylist. This
article may be of some assistants (read part one and two).
http://aspnet.4guysfromrolla.com/articles/102302-1.aspx

Mike
 
A

Aryan

Hi,
I am not able to understand one thing, if I have that data in
DataTable's Data Visualiser when I am in debug mode, then how can I am
not able to search for the same data using Select method. In normal
case, it should not show me that data in Visualiser which I am looking
for, or there is something worng with this case, like I can see the
data in Data Visualiser but I am not able to perform search on same
data using DataTable.Select() method.

Please suggest me how can this happen???

Thanks & Regards,
Manoj Singh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top