By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,225 Members | 2,172 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,225 IT Pros & Developers. It's quick & easy.

ASP paging problem

P: n/a
Hi
I have written code in ASP for paging records from the
database (SQL Server 2000).
The real problem I have around 10,000 records and it
tries to fetch all the records everytime (I'm saying
because its take a lot time to display it). Even though,
it displays all the data correctly and you can also
navigate through links.
Is it possible to set the limit on recordset while it
fetches the data. Lets say page size is 20 records per
page, so it should fetch only twenty records from the
database (depends on page being displayed) rather fetches
all records and displaying twenty records.
I know its possible if we use mysql database so can you
set the limit (its keyword) in the query statement.
Any help would be appreciated.
Thanx in advance...
Dave
Jul 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Some alternative approaches here. http://www.aspfaq.com/2120

If you can wait a few days, I'll probably have a much more comprehensive and
totally re-written article ready by Monday.

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/


"david" <an*******@discussions.microsoft.com> wrote in message
news:08****************************@phx.gbl...
Hi
I have written code in ASP for paging records from the
database (SQL Server 2000).
The real problem I have around 10,000 records and it
tries to fetch all the records everytime (I'm saying
because its take a lot time to display it). Even though,
it displays all the data correctly and you can also
navigate through links.
Is it possible to set the limit on recordset while it
fetches the data. Lets say page size is 20 records per
page, so it should fetch only twenty records from the
database (depends on page being displayed) rather fetches
all records and displaying twenty records.
I know its possible if we use mysql database so can you
set the limit (its keyword) in the query statement.
Any help would be appreciated.
Thanx in advance...
Dave

Jul 19 '05 #2

P: n/a

OP - Go with the DB Stored Proc way of paging... its MUCH MUCH Quicker
:)

Arron, are you rewriting the stored proc version? I'd be interest in
this if its even better :)

Al.

On Wed, 7 Jan 2004 23:13:10 -0500, "Aaron Bertrand [MVP]"
<aa***@TRASHaspfaq.com> wrote:
Some alternative approaches here. http://www.aspfaq.com/2120

If you can wait a few days, I'll probably have a much more comprehensive and
totally re-written article ready by Monday.


Jul 19 '05 #3

P: n/a
There will be a bunch of new stored procedure approaches. Just need to find
time to breathe first.

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/


"Harag" <ha***@REMOVETHESECAPITALSsofthome.net> wrote in message
news:8c********************************@4ax.com...

OP - Go with the DB Stored Proc way of paging... its MUCH MUCH Quicker
:)

Arron, are you rewriting the stored proc version? I'd be interest in
this if its even better :)

Al.

On Wed, 7 Jan 2004 23:13:10 -0500, "Aaron Bertrand [MVP]"
<aa***@TRASHaspfaq.com> wrote:
Some alternative approaches here. http://www.aspfaq.com/2120

If you can wait a few days, I'll probably have a much more comprehensive andtotally re-written article ready by Monday.

Jul 19 '05 #4

P: n/a

Hey Dave,

I hope you get this although the message is starting to age.

Try out my /coolpier_script/DBConn.asp. The paging function I use that
generally works really fast. It is located at ...

http://www.coolpier.com/cp/cp_script...ile=DBConn.asp

And it has...

cp_TheConnectionString

Sub cp_DBConn(cp_ConnAction) '// "open" or "close"

Sub cp_SqlExecute(cp_TheSqlStatement) '// one not returning a
recordset

Function cp_SqlArray(cp_TheSqlStatement) '//returns recordset as array

Function cp_DBPaging(cp_TheSQLStatement, cp_ThePageNumber,
cp_RecordsPerPage) '// returns that pages recordset as array

The 2 that return arrays, you will want to check if any records found
by ...

Your code would look similar to this...

<%
Dim pageNum, perPage
pageNum = CInt(Request.QueryString("page"))
perPage = 20

Dim yourArray, yourSQL, totalPagesOfRecords
cp_TheConnectionString = "DSN=yourDSN;"
yourSQL = "Select * From yourTable Where this = 'that';"

'// IN & OUT of database connection fast as heck ;)
cp_DBConn("open")
yourArray = cp_DBPaging(cp_TheSQLStatement, pageNum, perPage)
totalPagesOfRecords = cp_TotalPages
cp_DBConn("close")
If Not IsArray(yourArray) Then
'// No records found code
Else
'// Records found code
End If
%>

I will have more detailed instruction on my website very soon.
On Wed, 7 Jan 2004 19:53:40 -0800, "david"
<an*******@discussions.microsoft.com> wrote:
Hi
I have written code in ASP for paging records from the
database (SQL Server 2000).
The real problem I have around 10,000 records and it
tries to fetch all the records everytime (I'm saying
because its take a lot time to display it). Even though,
it displays all the data correctly and you can also
navigate through links.
Is it possible to set the limit on recordset while it
fetches the data. Lets say page size is 20 records per
page, so it should fetch only twenty records from the
database (depends on page being displayed) rather fetches
all records and displaying twenty records.
I know its possible if we use mysql database so can you
set the limit (its keyword) in the query statement.
Any help would be appreciated.
Thanx in advance...
Dave


I participate in the group to help give examples of code. I do not guarantee the effects of any code posted. Test all code before use!

Brynn
www.coolpier.com
Jul 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.