Filtering columns from datareader

G

Guest

Can I filter some columns out of a datareader in the code-behind? Or can I
convert a dataset into datareader?
 
G

Guest

Sandy,

AFAIK there are no built in methods to filter a datareader. It is just
that... a datareader. The best way would be to filter your results (in the
SQL Statement) before you populate the reader. A way to do this after you
have the results in the reader would be to do a comparison on each row as the
reader goes through its set. Depending on the comparison you could print out
the rows or (as in your other question) populate a DataSet.

If you are not locked down to a DataReader there are other ways to do this
using a DataSet or a DataView. Please reply to this post if this is not what
you are looking for.

I hope this helps.
 
G

Guest

Hi Brian,

Thx for your reply. I understand that there no built in methods to achieve
this and also that I can obtain a pre-filtered list from the SQL itself, but
that is what I was trying to avoid since then I'll need to maintain several
copies of my SQL statement (which is kind of convoluted).

If nothing else, I'll probably have to resort to this method. If I find a
better way, I'll post it here.

Thx,

Sandy
 

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

Top