ASP 101 - Active Server Pages 101 - Web04
The Place ASP Developers Go!

Please visit our partners

Windows Technology Windows Technology
15 Seconds
4GuysFromRolla.com
ASP 101
ASP Wire
VB Forums
VB Wire
WinDrivers.com
internet.commerce internet.commerce
Partners & Affiliates














ASP 101 is an
internet.com site
ASP 101 is an internet.com site
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

ASP 101 News Flash ASP 101 News Flash




Script Output:

Page 1 of 3

id last_name first_name sales
1 Fuller Andrew 5000
2 Leverling Janet 6250
3 Buchanan Steven 3245
4 Peacock Margaret 4685
5 King Robert 5290
6 Andersen David 6420
7 Edwards Frank 3840
8 Richards Kate 4260
9 Jones Edward 3450
10 Callahan Laura 3675
1 2 3 [Next >>]

ASP HTML Download            FAQ

Ever wonder how the search engines pull off that cool trick of only showing you the first ten results that your query pulls back from their gigantic database? Well, rest assured that you're not alone. It's been a popular request here at ASP 101, and as far as we can tell, everywhere else as well.

We did some research and there are a couple of ways to accomplish this particular trick. Since we're doing this for the web, one thing we decided was that we didn't want to leave any DB objects hanging around. This decision might hurt performance if you're going to be doing a lot of paging back and forth, but for us, it seemed to be worth the performace hit to not have the memory usage from unused DB objects lingering around in users' session objects.

If you're wondering, the reason we set the page size so small is because our sample DB is tiny and we figured a single page paging sample wouldn't illustrate the concept too well! The other thing to notice is that, besides the include at the top, this was all done in script. No context switching at all. I don't know if I like it or not, but I never felt the need to drop out to HTML and heck it's something else for you to notice!

The final thing I'd like you to notice is something everyone seems to compliain about! Take a look at our HTML source on this one. By my standards, the table's flawless! Everyone always complains that either their ASP code looks ugly or the reslting HTML output does. We really can't allow either one since our code is on public display. I'm showing you that you can get both to be presentable with a little work and some careful placement of vbCrLf's and vbTab's!

Once again, this is the same DB as our original Database sample. If for some reason you want a copy of the DB you can download it here.

Take a look through the code. There are some comments, but you'll find the level of sarcasm is lower than usual. Code, comments, and that's all folks!

Alternate Version Using an Array

One of our users has contributed a version of the script that copies the data to an array before implementing the paging.

Hi,

I reworked your database paging script to build an array and then close the connection. This keeps your paging model and reduces the time the SQL connection is open.

To be honest I'm not sure it'll be any faster (especially with larger data sets) but I figured I'd go ahead and post it for those of you who are interested. If anyone wants to speed test them I'll be happy to post the results... I just don't really have the time at the moment.

Anyway... you can download the code from here (1.5 KB).


Samples

Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback



JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
IBM eBook: Planning a Service Oriented Architecture
IBM eBook: Choosing the Right Architecture--What It Means for You and Your Business
Microsoft Article: Will Hyper-V Make VMware This Decade's Netscape?
Avaya Article: Using Intelligent Presence to Create Smarter Business Applications
Intel Go Parallel Article: Getting Started with TBB on Windows
Microsoft Article: 7.0, Microsoft's Lucky Version?
Avaya Article: How to Feed Data into the Avaya Event Processor
IBM Article: Developing a Software Policy for Your Organization
Microsoft Article: Managing Virtual Machines with Microsoft System Center
Intel Go Parallel Article: Intel Threading Tools and OpenMP
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
HP Video: StorageWorks EVA4400 and Oracle
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Red Gate Download: SQL Toolbelt and free High-Performance SQL Code eBook
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
Silverlight 2 App and Walkthrough: Leverage Silverlight 2 with SQL Server and XML
IBM Article: Enterprise Search--Do You Know What's Out There?
HP Demo: StorageWorks EVA4400
Microsoft Article: The Progress and Promise of Deep Zoom
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES