ASP 101 - Active Server Pages 101 - Web01
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
Microsoft Article: HyperV-The Killer Feature in WinServer ‘08
Avaya Article: How to Feed Data into the Avaya Event Processor
Microsoft Article: Install What You Need with Win Server ‘08
HP eBook: Putting the Green into IT
Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
Avaya Article: Setting Up a SIP A/S Development Environment
IBM Article: How Cool Is Your Data Center?
Microsoft Article: Managing Virtual Machines with Microsoft System Center
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
Intel Video: Are Multi-core Processors Here to Stay?
On-Demand Webcast: Five Virtualization Trends to Watch
HP Video: Page Cost Calculator
Intel Video: APIs for Parallel Programming
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
Sun Download: Solaris 8 Migration Assistant
Sybase Download: SQL Anywhere Developer Edition
Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
Red Gate Download: SQL Compare Pro 6
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
IBM Article: Collaborating in the High-Performance Workplace
HP Demo: StorageWorks EVA4400
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES