473,588 Members | 2,460 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Iterating through specific rows of DataReader...

Hi guys,
Say I made a SELECT statement to my sql DB that would return 50 rows
that I will use a sqldatareader to access. Instead of iterating through
each and every row of the datareader, I'd like to just iterate through,
say, rows 20 through 30.

How can one do this?

Thanks very much

Jacko

Nov 17 '05 #1
14 4319
Not possible, DataSet would be a candidate to start somewhere in the middle.

"Jacko" <ja******@greyk oko.com> wrote in message
news:3F******** ******@greykoko .com...
Hi guys,
Say I made a SELECT statement to my sql DB that would return 50 rows
that I will use a sqldatareader to access. Instead of iterating through
each and every row of the datareader, I'd like to just iterate through,
say, rows 20 through 30.

How can one do this?

Thanks very much

Jacko

Nov 17 '05 #2
Not possible, DataSet would be a candidate to start somewhere in the middle.

"Jacko" <ja******@greyk oko.com> wrote in message
news:3F******** ******@greykoko .com...
Hi guys,
Say I made a SELECT statement to my sql DB that would return 50 rows
that I will use a sqldatareader to access. Instead of iterating through
each and every row of the datareader, I'd like to just iterate through,
say, rows 20 through 30.

How can one do this?

Thanks very much

Jacko

Nov 17 '05 #3
If you only need rows 20-30, why return all 50? Possibly to use them afterwards - at some point. But you want to close the DataReader as soon as possible and don't keep the connection open.

The DataSet offers the disconnected architecture that you want.

Regards,
Wim Hollebrandse
http://www.wimdows.net
http://www.wimdows.com

---
Posted using Wimdows.net Newsgroups - http://www.wimdows.net/newsgroups/
Nov 17 '05 #4
If you only need rows 20-30, why return all 50? Possibly to use them afterwards - at some point. But you want to close the DataReader as soon as possible and don't keep the connection open.

The DataSet offers the disconnected architecture that you want.

Regards,
Wim Hollebrandse
http://www.wimdows.net
http://www.wimdows.com

---
Posted using Wimdows.net Newsgroups - http://www.wimdows.net/newsgroups/
Nov 17 '05 #5
Rajesh,

Just as I suspected. Thank you. One more question, though, if you will.
What if my SELECT statement gives 5,000 rows, or even 50,000. I want to
display this data only 50 rows per page. Would one populate a DataSet
with the entire 50,000 rows? Then programmaticall y display 50 at a time?
Or would one use a DataReader, and if one was viewing page 10, for
example, the program would skip the first 500 rows and then display 500
through 550?

Sorry if I'm a little too verbose about this. I just want the best way
to display a large amount of rows only a few rows per page.

Thanks very much for any help you can give. And thanks for your help to
everyone here, i see you have posted quite a few responses.

Jack

Rajesh.V wrote:
Not possible, DataSet would be a candidate to start somewhere in the middle.

"Jacko" <ja******@greyk oko.com> wrote in message
news:3F******** ******@greykoko .com...
Hi guys,
Say I made a SELECT statement to my sql DB that would return 50 rows
that I will use a sqldatareader to access. Instead of iterating through
each and every row of the datareader, I'd like to just iterate through,
say, rows 20 through 30.

How can one do this?

Thanks very much

Jacko



Nov 17 '05 #6
Rajesh,

Just as I suspected. Thank you. One more question, though, if you will.
What if my SELECT statement gives 5,000 rows, or even 50,000. I want to
display this data only 50 rows per page. Would one populate a DataSet
with the entire 50,000 rows? Then programmaticall y display 50 at a time?
Or would one use a DataReader, and if one was viewing page 10, for
example, the program would skip the first 500 rows and then display 500
through 550?

Sorry if I'm a little too verbose about this. I just want the best way
to display a large amount of rows only a few rows per page.

Thanks very much for any help you can give. And thanks for your help to
everyone here, i see you have posted quite a few responses.

Jack

Rajesh.V wrote:
Not possible, DataSet would be a candidate to start somewhere in the middle.

"Jacko" <ja******@greyk oko.com> wrote in message
news:3F******** ******@greykoko .com...
Hi guys,
Say I made a SELECT statement to my sql DB that would return 50 rows
that I will use a sqldatareader to access. Instead of iterating through
each and every row of the datareader, I'd like to just iterate through,
say, rows 20 through 30.

How can one do this?

Thanks very much

Jacko



Nov 17 '05 #7
Nice question, which occurs to most dealing with huge data reporting
requiremnets.

Now for this, you will have to fool the user to thinking he can access any
record out of the data store. That is by using...
1. A search page which narrows down the result to manageable qty.
2. Now if he still wants to wade thru 50k or higher record we have to do
some tricky programming. will take time but worth the effort. So here goes.

a. first show him 20 records, (as much as can fit in a screen).
b. then when he requests to see next page fetch the next 20 records.
c. This way u have to keep the begin and end record numbers in a hidden
field.
d. Use custom paging which exposes the events next page and previous page of
the DataGrid.

At the db level say a storedproc accepts two params begin and start. Here is
where your Sql magic has to be worked in
extracting only the recordset for a given sql (say 25000 - 25100).

Also if you have a large no. of reports, duplicating the above is going to
be trying. Try dbnetgrid.com, their dbgrid is really good, i still don know
whether the component pulls all the records or a slice of them. The grid
handles this beautifully without any postback. Pagination comes with the
component as well as conversion to excel/xml/pdf.....
"Jacko" <ja******@greyk oko.com> wrote in message
news:3F******** ******@greykoko .com...
Rajesh,

Just as I suspected. Thank you. One more question, though, if you will.
What if my SELECT statement gives 5,000 rows, or even 50,000. I want to
display this data only 50 rows per page. Would one populate a DataSet
with the entire 50,000 rows? Then programmaticall y display 50 at a time?
Or would one use a DataReader, and if one was viewing page 10, for
example, the program would skip the first 500 rows and then display 500
through 550?

Sorry if I'm a little too verbose about this. I just want the best way
to display a large amount of rows only a few rows per page.

Thanks very much for any help you can give. And thanks for your help to
everyone here, i see you have posted quite a few responses.

Jack

Rajesh.V wrote:
Not possible, DataSet would be a candidate to start somewhere in the middle.
"Jacko" <ja******@greyk oko.com> wrote in message
news:3F******** ******@greykoko .com...
Hi guys,
Say I made a SELECT statement to my sql DB that would return 50 rows
that I will use a sqldatareader to access. Instead of iterating through
each and every row of the datareader, I'd like to just iterate through,
say, rows 20 through 30.

How can one do this?

Thanks very much

Jacko


Nov 17 '05 #8
Nice question, which occurs to most dealing with huge data reporting
requiremnets.

Now for this, you will have to fool the user to thinking he can access any
record out of the data store. That is by using...
1. A search page which narrows down the result to manageable qty.
2. Now if he still wants to wade thru 50k or higher record we have to do
some tricky programming. will take time but worth the effort. So here goes.

a. first show him 20 records, (as much as can fit in a screen).
b. then when he requests to see next page fetch the next 20 records.
c. This way u have to keep the begin and end record numbers in a hidden
field.
d. Use custom paging which exposes the events next page and previous page of
the DataGrid.

At the db level say a storedproc accepts two params begin and start. Here is
where your Sql magic has to be worked in
extracting only the recordset for a given sql (say 25000 - 25100).

Also if you have a large no. of reports, duplicating the above is going to
be trying. Try dbnetgrid.com, their dbgrid is really good, i still don know
whether the component pulls all the records or a slice of them. The grid
handles this beautifully without any postback. Pagination comes with the
component as well as conversion to excel/xml/pdf.....
"Jacko" <ja******@greyk oko.com> wrote in message
news:3F******** ******@greykoko .com...
Rajesh,

Just as I suspected. Thank you. One more question, though, if you will.
What if my SELECT statement gives 5,000 rows, or even 50,000. I want to
display this data only 50 rows per page. Would one populate a DataSet
with the entire 50,000 rows? Then programmaticall y display 50 at a time?
Or would one use a DataReader, and if one was viewing page 10, for
example, the program would skip the first 500 rows and then display 500
through 550?

Sorry if I'm a little too verbose about this. I just want the best way
to display a large amount of rows only a few rows per page.

Thanks very much for any help you can give. And thanks for your help to
everyone here, i see you have posted quite a few responses.

Jack

Rajesh.V wrote:
Not possible, DataSet would be a candidate to start somewhere in the middle.
"Jacko" <ja******@greyk oko.com> wrote in message
news:3F******** ******@greykoko .com...
Hi guys,
Say I made a SELECT statement to my sql DB that would return 50 rows
that I will use a sqldatareader to access. Instead of iterating through
each and every row of the datareader, I'd like to just iterate through,
say, rows 20 through 30.

How can one do this?

Thanks very much

Jacko


Nov 17 '05 #9
fdg
Rajesh,

We think alike. This is the way I had it before. But since i sometimes
have to delete rows, consecutive record numbers arent always 1,2,3,4,5
but can be 1,3,4,6, since i deleted 2 and 5 (for example). So a sql
query based purely on record number won't give me completely accurate
results if some of the rows are missing, thus the pattern of
consecutively growing record numbers is broken.

Would it be much of a performance hit if I do a datareader and just
DataReader.Read () through them until I get to the desired range? Even if
I go through, say, 500, or 1,000?

You're a big asset to this newsgroup!!

Rajesh.V wrote:
Nice question, which occurs to most dealing with huge data reporting
requiremnets.

Now for this, you will have to fool the user to thinking he can access any
record out of the data store. That is by using...
1. A search page which narrows down the result to manageable qty.
2. Now if he still wants to wade thru 50k or higher record we have to do
some tricky programming. will take time but worth the effort. So here goes.

a. first show him 20 records, (as much as can fit in a screen).
b. then when he requests to see next page fetch the next 20 records.
c. This way u have to keep the begin and end record numbers in a hidden
field.
d. Use custom paging which exposes the events next page and previous page of
the DataGrid.

At the db level say a storedproc accepts two params begin and start. Here is
where your Sql magic has to be worked in
extracting only the recordset for a given sql (say 25000 - 25100).

Also if you have a large no. of reports, duplicating the above is going to
be trying. Try dbnetgrid.com, their dbgrid is really good, i still don know
whether the component pulls all the records or a slice of them. The grid
handles this beautifully without any postback. Pagination comes with the
component as well as conversion to excel/xml/pdf.....
"Jacko" <ja******@greyk oko.com> wrote in message
news:3F******** ******@greykoko .com...
Rajesh,

Just as I suspected. Thank you. One more question, though, if you will.
What if my SELECT statement gives 5,000 rows, or even 50,000. I want to
display this data only 50 rows per page. Would one populate a DataSet
with the entire 50,000 rows? Then programmaticall y display 50 at a time?
Or would one use a DataReader, and if one was viewing page 10, for
example, the program would skip the first 500 rows and then display 500
through 550?

Sorry if I'm a little too verbose about this. I just want the best way
to display a large amount of rows only a few rows per page.

Thanks very much for any help you can give. And thanks for your help to
everyone here, i see you have posted quite a few responses.

Jack

Rajesh.V wrote:

Not possible, DataSet would be a candidate to start somewhere in the
middle.
"Jacko" <ja******@greyk oko.com> wrote in message
news:3F***** *********@greyk oko.com...
Hi guys,
Say I made a SELECT statement to my sql DB that would return 50 rows
that I will use a sqldatareader to access. Instead of iterating through
each and every row of the datareader, I'd like to just iterate through,
say, rows 20 through 30.

How can one do this?

Thanks very much

Jacko



Nov 17 '05 #10

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

Similar topics

1
1170
by: Claudia Fong | last post by:
Hi, I'm using a DataReader to connect to a db and retrieve data from the db. I just wondering how can I know the numbers of rows contain in my DB for the sql statement I used? For example, if the sql statement is like this: SELECT * FROM DEPT;
0
338
by: Jacko | last post by:
Hi guys, Say I made a SELECT statement to my sql DB that would return 50 rows that I will use a sqldatareader to access. Instead of iterating through each and every row of the datareader, I'd like to just iterate through, say, rows 20 through 30. How can one do this?
2
1569
by: Andrew | last post by:
Hey all, Have a strange one here, and being still fairly new to .NET isn't helping me understand it. I am having a problem where a DataReader doesn't return all the rows when I try to use a method from a separate class file that returns a DataReader, where when I code the DataReader in the .aspx file it does. Below are the details and code of what I am runnign into. I appreciate any help/insight you can provide.
1
2200
by: ae | last post by:
My datareader looks like this where dtrItemList is the datareader and chklExceptionList is my checkboxlist. the rows come in just fine, but I need help also including the name of the columns for my rows. I need them listed only one time on top. Any idea? Thanks in advance. while (dtrItemList.Read()) { chklExceptionList.Items.Add(dtrItemList.ToString() + " " + dtrItemList "item_name"].ToString());
3
2620
by: hazz | last post by:
The datareader below contains two rows of two columns but in the for loop, the values for only the first row are getting printed twice. How do I get to the values of the second row? Thanks. -hazz Dim dTable As DataTable Dim dsBlock As New DataSet Dim rowBlock As DataRow Dim myColumn As DataColumn Dim iCol As Integer = 0
6
8468
by: dew | last post by:
How do I get the number of rows a datareader has? I can tell HasRows, but not how many. Thanks.
2
2513
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, i want to loop thru my datareader to get all the fieldnames, what's the best way to do this? thanks, rodchar
0
7929
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7860
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8222
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8223
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5398
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3847
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3883
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1458
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1195
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.