ASP paging problem

D

david

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
 
H

Harag

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.
 
B

Brynn

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_scripts/script.asp?view=code&file=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.


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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top