How to get value from SQLDataReader

  • Thread starter Thread starter teresa
  • Start date Start date
T

teresa

Hi Everyone,

I appreciate any help if any of you know or have used this method
before and can give me some suggestion. It's a bit difficult to
explain:

Here is my table:

Table1: there are 4 columns in this table as follow:
Column1 | Column2 | Column3 | Column4 |
A | 5 | xyz | 10 |
B | 7 | abc | 10 |
D | 6 | npq | 10 |
...................
...................
When I need to display these values ('xyz','abc', etc) in a website, I
need some way to reference them after I used SqlDataReader to retrieve
all the data from this table.

Some one says that I can use:

For example: FieldName.text = Page.getControl("A")("5") --> this will
get 'xyz'. I tried but id did not work.
If you know some other way, please drop me a line.
All help are much appreciated!

Teresa
 
If you want to (re)look at the values.

Then you can either put the original data inside a DataSet (and not an
IDataReader)

OR

You can populate another object using your IDataReader.

You cannot (re) use a IDataReader


When I need to (re)use values , especially in a web environment, I put the
data into a DataSet.
And then use the DataSet.SomeTable.Select method.


You can check out
http://sholliday.spaces.live.com/?_...ogview&_c=blogpart&partqs=amonth=5&ayear=2006
May 2005 entry

for how to use an IDataReader to populate Custom Objects/Collections
 
Teresa,
If you want to hold onto the values in tabular format for display or
manipulation in a web application, you will be better served by getting a
DataSet rather than a DataReader. Your single table will be in your DataSet,
which is disconnected and available after your Connection is closed. You can
further store this in Session, Cache or even Application state so that it is
available from any web page in your application.

There is some additional overhead in returning a DataSet instead of a
DataReader, but in all but the most exceptional cases, it will be negligible.
Peter
 
Back
Top