473,406 Members | 2,467 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,406 software developers and data experts.

SQLDataReader

Dom
In the old days, using ADO, I used to be able to move up and down in a
resultset, but using functions like MoveNext, MoveFirst, MoveLast,
MovePrev. I don't see any of that in the SQLDataReader object. It
seems I can only move through it sequentially. Is that true?

Dom
Dec 11 '07 #1
3 4176
Dom,

Yes, that is true. The SqlDataReader (or any class that derives from
DbDataReader, really) is meant for forward-only, read-only access.

If you want to move through a set of data, then you will need to load
the data into a DataTable, through a DbDataAdapter derivative (in this case,
SqlDataAdapter) and then you can cycle through the rows in any way that you
wish.

Mind you that doing it in this way is going to be the equivalent of
setting the cursor location on an ADODB Recordset to adUseClient, and then
loading the data statically (adOpenStatic). Basically, the DataTable is an
in-memory representation of the result set.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Dom" <do********@gmail.comwrote in message
news:21**********************************@e10g2000 prf.googlegroups.com...
In the old days, using ADO, I used to be able to move up and down in a
resultset, but using functions like MoveNext, MoveFirst, MoveLast,
MovePrev. I don't see any of that in the SQLDataReader object. It
seems I can only move through it sequentially. Is that true?

Dom

Dec 11 '07 #2
Dom
Thanks for clarifying this. BTW, you've answered so many of my
questions, I feel like you're my private tutor.

Dom

On Dec 11, 1:28 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
Dom,

Yes, that is true. The SqlDataReader (or any class that derives from
DbDataReader, really) is meant for forward-only, read-only access.

If you want to move through a set of data, then you will need to load
the data into a DataTable, through a DbDataAdapter derivative (in this case,
SqlDataAdapter) and then you can cycle through the rows in any way that you
wish.

Mind you that doing it in this way is going to be the equivalent of
setting the cursor location on an ADODB Recordset to adUseClient, and then
loading the data statically (adOpenStatic). Basically, the DataTable is an
in-memory representation of the result set.

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

"Dom" <dolivas...@gmail.comwrote in message

news:21**********************************@e10g2000 prf.googlegroups.com...
In the old days, using ADO, I used to be able to move up and down in a
resultset, but using functions like MoveNext, MoveFirst, MoveLast,
MovePrev. I don't see any of that in the SQLDataReader object. It
seems I can only move through it sequentially. Is that true?
Dom- Hide quoted text -

- Show quoted text -
Dec 11 '07 #3
Can I send you a bill? =) J/K
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Dom" <do********@gmail.comwrote in message
news:7d**********************************@t1g2000p ra.googlegroups.com...
Thanks for clarifying this. BTW, you've answered so many of my
questions, I feel like you're my private tutor.

Dom

On Dec 11, 1:28 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
>Dom,

Yes, that is true. The SqlDataReader (or any class that derives from
DbDataReader, really) is meant for forward-only, read-only access.

If you want to move through a set of data, then you will need to load
the data into a DataTable, through a DbDataAdapter derivative (in this
case,
SqlDataAdapter) and then you can cycle through the rows in any way that
you
wish.

Mind you that doing it in this way is going to be the equivalent of
setting the cursor location on an ADODB Recordset to adUseClient, and
then
loading the data statically (adOpenStatic). Basically, the DataTable is
an
in-memory representation of the result set.

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

"Dom" <dolivas...@gmail.comwrote in message

news:21**********************************@e10g200 0prf.googlegroups.com...
In the old days, using ADO, I used to be able to move up and down in a
resultset, but using functions like MoveNext, MoveFirst, MoveLast,
MovePrev. I don't see any of that in the SQLDataReader object. It
seems I can only move through it sequentially. Is that true?
Dom- Hide quoted text -

- Show quoted text -

Dec 11 '07 #4

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

Similar topics

3
by: Ricola ! | last post by:
Why do I say: SqlDataReader dr; instead of SqlDataReader dr = new SqlDataReader();
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:...
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: Arvind P Rangan | last post by:
Hi All, How do you get all the values of a sqldatareader if it contains multiple resultset. Using sqldatareader.nextresult and sqldatareader.read e.g. While sqldatareader.read ' If not...
4
by: Michael Carr | last post by:
I have a function that populates a class with values from a database. I'd like to pass into the function either a SqlDataReader or a DataRow, depending on which mechanism I'm using to retrieve data...
1
by: me | last post by:
Why is SqlDataReader not present in visual studios Toolbox->Data where I find components like DataSet? Most examples in books and in vs.net are based on datasets but using disconnected tables seems...
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:...
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...
7
by: Web learner | last post by:
I am trying to create a method GetDataFor(string column) becaues I have to repeat the same statements for several columns but I get an error as follows: The name 'dr' does not exist in the current...
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: 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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.