473,396 Members | 1,725 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to get value from SQLDataReader

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

Oct 9 '06 #1
2 6411


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/?_c...26ayear%3d2006
May 2005 entry

for how to use an IDataReader to populate Custom Objects/Collections

"teresa" <le******@yahoo.comwrote in message
news:11*********************@h48g2000cwc.googlegro ups.com...
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

Oct 9 '06 #2
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

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"teresa" wrote:
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

Oct 9 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Franck Diastein | last post by:
Hi, when I call ExportData I have this error: Invalid attempt to Read when reader is closed. Telling me that there's a problem with this line: while(_dataR.Read()){ Code:...
12
by: Jose Fernandez | last post by:
Hello. I'm building a web service and I get this error. NEWS.News.CoverNews(string)': not all code paths return a value This is the WebMethod public SqlDataReader CoverNews(string Sport)...
3
by: Neil Guyette | last post by:
Hello, Everyone, I'm trying to find information on how to populate a combo box using a SqlDataReader. I want to be able to set the value of the combo's value property different then the...
1
by: Neo Chou | last post by:
Greetings! I met the same question as in ADO a few months ago. I'm working on MS SQL Server 2000. I have a stored procedure that returns a return value as well as a record set (by "select"...
8
by: bidllc | last post by:
I have a funtion that works fine and dandy when called from anywhere in my app. It will NOT work when called from inside the class in which it resides. This is the function I'm calling:...
3
by: tshad | last post by:
I am trying to set up a class to handle my database accesses. I can't seem to figure out how to get the return value from my dataReader from these routines (most of which I got elsewhere). They...
4
by: mimi | last post by:
Hi Please help me out, I can't find a way to close a sqldatareader when error occur at statement cmd.ExecuteReader(). I can't close it in catch because it is local in try scope and I can't...
2
by: SQL | last post by:
I'm new at this, so please forgive me if my question has a simple answer to it. I'm trying to get a value out of a SqlDataReader. Here is my code to do so: Dim mySQLCommand As New...
3
by: Jon Haakon Ariansen | last post by:
Hi, I realize that it's not possible to get the rowcount from SqlDataReader, but if you have a stored procedure where you return @@ROWCOUNT it should be possible to get the rowcount through the...
3
by: Frank Milverckowitz | last post by:
Hi, Newbie question about SqlDataReader column value access... In java jdbc code to get a value from a table column we can pass the column name (instead of an int index or offset): String...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.