Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 19th, 2005, 10:58 AM
david
Guest
 
Posts: n/a
Default ASP paging problem

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
  #2  
Old July 19th, 2005, 10:58 AM
Aaron Bertrand [MVP]
Guest
 
Posts: n/a
Default Re: ASP paging problem

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" <anonymous@discussions.microsoft.com> wrote in message
news:08f201c3d59b$0074fd20$a101280a@phx.gbl...[color=blue]
> 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[/color]


  #3  
Old July 19th, 2005, 10:58 AM
Harag
Guest
 
Posts: n/a
Default Re: ASP paging problem


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]"
<aaron@TRASHaspfaq.com> wrote:
[color=blue]
>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.[/color]

  #4  
Old July 19th, 2005, 10:58 AM
Aaron Bertrand - MVP
Guest
 
Posts: n/a
Default Re: ASP paging problem

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" <harag@REMOVETHESECAPITALSsofthome.net> wrote in message
news:8chqvvov5dt9hjlt2p1gsmat9thm726c0f@4ax.com...[color=blue]
>
> 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]"
> <aaron@TRASHaspfaq.com> wrote:
>[color=green]
> >Some alternative approaches here. http://www.aspfaq.com/2120
> >
> >If you can wait a few days, I'll probably have a much more comprehensive[/color][/color]
and[color=blue][color=green]
> >totally re-written article ready by Monday.[/color]
>[/color]


  #5  
Old July 19th, 2005, 11:03 AM
Brynn
Guest
 
Posts: n/a
Default Re: ASP paging problem


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"
<anonymous@discussions.microsoft.com> wrote:
[color=blue]
>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[/color]

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
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles