Classic ASP: More Efficient Database Recordset, GetRows() XoiseRecordset

I’ve created what I believe to be a more efficient recordset object for traversing rows returned from a database query. I implemented all methods/properties that I feel make sense to implement. There’s definite room for improvement, but it’s a good start. My reasoning for creating this is that I like the functionality of using recordsets (via Server.CreateObject("ADODB.Recordset")), but there is a HUGE drawback in that it is horrible on the database. The Server.CreateObject approach makes a database call every time a EOF, BOF, or a traversal method (ie. MoveNext, MovePrevious, etc.) is called.

My fix is to use the GetRows() method to return it as a multidimensional array and just implement my own class with the same (or similar) functionality. There is also an advantage to using this Recordset over just plain using the GetRows() method. I went ahead and implemented a way to extract the column names from the query, which allows you to grab the information using the column name, instead of the index of the array (ie. objRS("Column_Name")). You may also access the data using the column index if you prefer. Note that I haven’t implemented support for "SELECT * FROM Tbl…" syntax, so you’ll HAVE to use the index for this.

There is one main usage difference to note. Rather than opening the recordset with .Open SQL_String, Connection_Object, you must individually update the .Conn and .SQL properties. I’ll most likely change this if there is enough interest and I create a newer version. If I do that, I’ll most likely provide cache support.

Download: XoiseRecordset.zip (1.29KB)

Usage:

Retrieve Data:

  • objRS("Column_Name")
  • objRS.Item("ColumnName")
  • objRS.Row(0)

Implemented Methods/Properties:

  • Conn
  • SQL
  • EOF()
  • BOF()
  • MoveNext()
  • MoveFirst()
  • MoveFirst()
  • MoveLast()
  • Move()
  • GetRows()
  • RecordCount()
  • PageCount()
  • PageSize()
  • AbsolutePage()
  • AbsolutePosition()

How To: Create a Simple Visual “Loading” Effect

If you've got a script that takes a while to load and want to make your user aware that everything is alright, then this tool is for you. The idea is simple – display the message before the labor intensive part of the script runs, and then using CSS after the labor intensive part of the script, hide the message. If you're using a language that provides a buffer (ASP for instance), make sure you turn the buffer off first, or this won't have any effect. (eg. Response.Buffer = False) Example (See it in action):

<?php
ini_set('implicit_flush', 'on');

echo '<p id="loading_msg"><img src="http://img520.imageshack.us/img520/4950/loadingvp7.gif" alt="" style="vertical-align: middle;" /> Loading...</p>';

// Code that takes forever here, could of course be any language
sleep(5); // Only for demonstration

echo '<script type="text/javascript">
window.onload = init;

function init() {
	document.getElementById("loading_msg").style.display = "none";
}
</script>';
echo '<p>Woohoo, five seconds passed.</p>';

require_once('includes/trackers.inc.php');
?>

How to connect your laptop to the internet through your Motorola Razr

[ad]I wouldn’t say this is a web tool, but it could certainly come in handy for those who want to use web tools anywhere they can get a cell phone connection!

By now, I’m sure most people are aware that you can connect your laptop to the internet through your cell phone. However, if you’re like I was a couple of hours ago, you don’t know how. It’s really not too bad to do, unless you run into problems.

What you need:

  • Cell Phone
  • USB Cable (you can use bluetooth as well)
  • Not required, but nearly essential: Unlimited data plan (otherwise you’ll rack up HUGE charges)

Here’s a step-by-step for what I did:

  1. Disable EVDO on your phone. Basically, your phone constantly checks two different types of connections, and you’re disabling one of them.  By doing this, you shouldn’t see any difference in your phone’s connection, but you will be able to use your phone as a modem and you will actually get better battery life on your phone.  To disable EVDO, use this guide.
  2. Make sure your Phone is in “Modem/COM” mode. From the main menu, go to Settings -> Connection -> USB Settings. Make sure Default: is set to “Modem/COM.”
  3. Connect your cell phone to your laptop with the USB cable. Your computer should automatically recognize it and install the proper drivers. (Note: Make sure that whenever you do this, you plug it in the same USB port [otherwise it will want to install drivers for each port].)
  4. Open the Device Manager from the Control Panel. Under “Modems,” make sure that you see your phone there (it’ll say something with Motorola in it). If it’s not there, you’re missing some driver. Check out the guides and downloads at HackTheRazr.
  5. If you see your phone under “Modems,” you’re almost there! Follow the following steps to create a new network connection through your phone:
    • Create a new network connection (from the menu in the Network and Sharing Center in Vista or somewhere in the control panel in XP)
    • Choose “Set up a dial-up connection.”
    • For the dial-up phone number, put in #777. Leave the username & password blank. Give your connection name a name of whatever you want. Click connect.
    • BAM. You should be able to use the internet now.

Website Monitoring Service

[ad]I use Site24x7 for my website monitoring service – it’s nice because you can be notified via email and/or SMS whenever your site goes down. Sorry, it’s not free – I only use it because I signed up when they started and was grandfathered in. The website I’ve been working on has recently been having a lot of problems and I wanted to keep close tabs on it. This runs into a problem because Site24x7 only allows a maximum of 5 minute intervals for site requests.

A quick search on Google found HostTracker. It’s a handy web tool which does every Site24x7 can do (as far as I can tell). Better than that though, the 30 day trial allows up to 1 minute site request intervals…bingo! Very handy. The site is very easy to use and very helpful. I’d definitely recommend giving it a try.

The Gratitude Campaign

This is obviously an aside to the web tools I usually post about.

As the son of a 20+ year, 3 time war Army vet and brother of a ROTC cadet, I feel the need to help spread the word about a new effort to show our gratitude for our brave armed forces.

From an email I received:

Have you ever seen one of our military walking past you and wanted to convey
to them your thanks, but weren’t sure how or it felt awkward?

Recently, a gentleman from Seattle created a gesture which could be used and
has started a massive movement to get the word out.

Please everybody take just a moment to watch…. The Gratitude Campaign
…and then forward it to your friends!

Click on below.

http://www.gratitudecampaign.org/shortmovie.php