473,327 Members | 1,967 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,327 software developers and data experts.

Paging a SqlDataReader in C#

Is there a way to setup paging with a data reader? For instance, I only want 10 records at a time, and I can move through the next ten when I need them. From the members that I saw listed in the MSDN library, it does not appear that there is. Can someone please help? Also, is there a way to find out the number of results that a stored procedure returns?
Nov 18 '05 #1
3 1617
There is no paging build into the SqlDataReader. You usually bind it to a datagrid and then turn on paging for the grid by setting the AllowPaging to true and handling the PageIndexChanged event.
--
Hope this helps,
Bryant Hankins
Numinet Systems Inc.
http://www.numinet.com/blogging

"Jeremy Ames" <yo******@here.com> wrote in message news:eM*************@TK2MSFTNGP12.phx.gbl...
Is there a way to setup paging with a data reader? For instance, I only want 10 records at a time, and I can move through the next ten when I need them. From the members that I saw listed in the MSDN library, it does not appear that there is. Can someone please help? Also, is there a way to find out the number of results that a stored procedure returns?
Nov 18 '05 #2
A dataReader is a forward only cursor. You can roll your own, of course, but
the whole idea of the DataReader is you are simply streaming data in until
you get to the end. It does not even know how many records until it is done.

I would switch to a DataSet and be done with it.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
"Jeremy Ames" <yo******@here.com> wrote in message
news:eM*************@TK2MSFTNGP12.phx.gbl...
Is there a way to setup paging with a data reader? For instance, I only want
10 records at a time, and I can move through the next ten when I need them.
From the members that I saw listed in the MSDN library, it does not appear
that there is. Can someone please help? Also, is there a way to find out the
number of results that a stored procedure returns?
Nov 18 '05 #3
That worked well. I just had to teach myself how to use the dataset objects.
Thanks for your help.

"Cowboy (Gregory A. Beamer) [MVP]" <No************@comcast.netNoSpamM> wrote
in message news:uW**************@TK2MSFTNGP09.phx.gbl...
A dataReader is a forward only cursor. You can roll your own, of course, but
the whole idea of the DataReader is you are simply streaming data in until
you get to the end. It does not even know how many records until it is done.

I would switch to a DataSet and be done with it.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
"Jeremy Ames" <yo******@here.com> wrote in message
news:eM*************@TK2MSFTNGP12.phx.gbl...
Is there a way to setup paging with a data reader? For instance, I only want
10 records at a time, and I can move through the next ten when I need them.
From the members that I saw listed in the MSDN library, it does not appear
that there is. Can someone please help? Also, is there a way to find out the
number of results that a stored procedure returns?

Nov 18 '05 #4

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

Similar topics

2
by: Jeremy Ames | last post by:
Is there a way to setup paging with a data reader? For instance, I only want 10 records at a time, and I can move through the next ten when I need them. From the members that I saw listed in the MSDN...
1
by: Paul Hobbs | last post by:
Hi Everyone, I am trying to implement a DataGrid that uses Custom paging, but the DataSource is a SQLDataReader, not a DataSet. I have seen examples that use the Fill method of a DataAdapter to...
1
by: Quentin Huo | last post by:
Hi, There is a page in my project which is just to list the all article titles by paging (20 titles per page). So I think it might be more efficient using SqlDataReader instead of DataSet. But...
5
by: Patrick.O.Ige | last post by:
Hi Guys, I have a datagrid wit editing and updating. But after adding Paging IT WON'T PAGE!! It compiles well but when i click on the paging link it doesn't go to the next link.. When i remove...
1
by: Patrick.O.Ige | last post by:
I have been paging with DataSet using "DataGridPageChangedEventArgs" and i guess it works with only Dataset because default paging requires that the DataGrid be able to determine the number of...
1
by: hoz | last post by:
Hi , I use a procedure to get list of all users and show them in a datagrid/datalist/etc.. with SqlDataReader . How can i list X item (lets say 50) on the first page , 2. 50 on second page and so...
3
by: Darren | last post by:
Dear Groups I've used paging with a datagrid in C# at least a hundred times, but for whatever reason, I cannot get the prev /next to appear as links. It is absolutely certain that the number of...
0
by: Tim::.. | last post by:
Hi... I'm having a big problem with a datagrid that obtains data from 2 different locations... Active Directory and SQL Database The data is inserted into a datatable and the sorted by a...
6
by: Natan Vivo | last post by:
I had to built a custom data paging control for my asp.net app and SQL Server. This is what I'm doing: 1. do a SELECT to a SqlDataReader 2. create a DataTable with data from GetSchema() 3....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.