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 " 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
Application.Unlock
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
jlewis@jimbabwe.com

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

Dig deeper on .NET Framework security best practices

0 comments

Oldest 

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:

-ADS BY GOOGLE

SearchCloudComputing

SearchSoftwareQuality

SearchSOA

TheServerSide

SearchCloudApplications

Close