PC Review


Reply
Thread Tools Rating: Thread Rating: 3 votes, 1.00 average.

DataTable.Select problem in ASP.NET 2.0

 
 
Aryan
Guest
Posts: n/a
 
      29th Aug 2006
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

 
Reply With Quote
 
 
 
 
Marina Levit [MVP]
Guest
Posts: n/a
 
      29th Aug 2006
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.

"Aryan" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
vMike
Guest
Posts: n/a
 
      29th Aug 2006

"Aryan" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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


 
Reply With Quote
 
vMike
Guest
Posts: n/a
 
      29th Aug 2006
This should say strongly typed class not serialized. Sorry.


Mike


> 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
>
>



 
Reply With Quote
 
Aryan
Guest
Posts: n/a
 
      30th Aug 2006
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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with Select in datatable perspolis Microsoft C# .NET 4 30th May 2007 04:31 PM
DataTable.Select problem in ASP.NET 2.0 manoj241176@gmail.com Microsoft ADO .NET 1 30th Aug 2006 12:24 PM
datatable.select problem Frank Microsoft C# .NET 9 4th Apr 2005 02:18 PM
DataTable.Select problem Alex Markov Microsoft ADO .NET 2 6th Sep 2003 05:13 PM
DataTable.Select problem Alex Markov Microsoft VB .NET 1 5th Sep 2003 11:15 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:20 PM.