Jul 04 2001

Access database

Posted by admin under ADO database

A:
<%
Function Incdb_GetConnection( sConnString )
     Dim oConn
        
    Set oConn = Server.CreateObject("ADODB.Connection")
    oConn.Open sConnString
    Set Incdb_GetConnection  = oConn 
End Function
%>


Be sure to save this function in a general include file, called maybe incdb.asp and have all your other pages include that file.

Usage example:
<%
OPTION EXPLICIT
%>
<!--#include virtual="/include/incdb.asp"-->
<%
Dim oConn, sConnString
sConnString = Incdb_GetConnectionString( 0 )
Set oConn = Incdb_GetConnection( sConnString )
%>