DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Heist Guest

    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.

  2. #2
    AtomicBob Guest

    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.



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


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


Sponsored Links