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