Problem solve Get help with specific problems with your technologies, process and projects.

Testing application variables

Jim uses a lot of ADO connections in his Active Server Pages development, but NT servers can cause problems.

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 "" 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 denim shirt. Wear it in good health!

Jim Lewis

Jim is the owner of "Jimbabwe" (, 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.

Dig Deeper on .NET Framework security best practices

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.