-
Checking for connection
How can you check if a connection to an Access DB is open in ASP? I know in
PHP it would look something like :
if(! $link) //checks if link doesn't exists
$link = mysql_connect("mysql_host", "mysql_login", "mysql_password"); //connects
This is very useful when you want to include your connection code in a single
file that every other page can use.
-
Re: Checking for connection
I am not positive, but I don't think you can create a connection in one ASP
file and attempt to use that same connection in another file.
My suggestion, create a file include with the following code.
<%
Const conConnectionString = "<Your connection string or DSN>"
Dim objConn ' Connection Object
Sub subOpenDatabase
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open conConnectionString
End Sub
Sub subCloseDatabase
objConn.Close
Set objConn = Nothing
End Sub
%>
This code can be called from any page that has the include file. It is a
quick and dirty way to create/destroy connection objects.
- AtomicBob
"Heist" <homelesspunk@hotmail.com> wrote:
>
>How can you check if a connection to an Access DB is open in ASP? I know
in
>PHP it would look something like :
>if(! $link) //checks if link doesn't exists
>$link = mysql_connect("mysql_host", "mysql_login", "mysql_password"); //connects
>
>This is very useful when you want to include your connection code in a single
>file that every other page can use.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks