Testing application variables

Testing Application variables

Reader, Jim Lewis of Fairfield, California, USA, submitted this week's tip. Jim uses a lot of ADO connections in his Active Server Pages development to make things more user friendly, and of course to create dynamic data pages.

Unfortunately, Jim finds that NT web-hosting servers aren't always as reliable as he would like them to be, and the Application connection variables in his global.asa file sometimes "evaporate". Since he can't check every site every day, he's found it useful to include a short test to see if the Application variables are valid, and reset them if not.

At the top of his index.asp page, Jim uses an include file "conn_test.inc" which looks something like this:

<% language="vbscript" RUNAT=SERVER %>
If Application("myConn_ConnectionString") = "" Then 'run if
ConnectionString has been lost
Application.Lock 'Lock App while we reset
Application("myConn_ConnectionString") = "DBQ={appropriate
connection string}
Application("myConn_ConnectionTimeout") = 15
Application("myConn_CommandTimeout") = 30
Application("myConn_CursorLocation") = 3 'use client side cursor
Application("myConn_RuntimeUserName") = "admin" 'true for most MS
Access databases
End If

This assures Jim that when a visitor accesses the site, it will work like it should. Not to mention, Jim also avoids embarrassing emails telling him his client's site is "broken".

Jim, that's a useful tip for our readers, and to show our appreciation, we're sending you a free searchVB.com denim shirt. Wear it in good health!

Jim Lewis

Jim is the owner of "Jimbabwe" (http://jimbabwe.com), a company that focuses on database consulting, software development using Internet technology, and web application development. In addition, Jim is a Workflow System Engineer at NorthBay Healthcare System, where he implemented and maintains a corporate Intranet, is webmaster of the corporate Internet site, and develops collaborative online applications using MS Outlook and Exchange. In both jobs, Jim uses Visual Basic and VBScript extensively.

This was first published in August 2000

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.