ADO Open Method

Definition and Usage

The Open method can open a connection to a data source. When the connection is open, you can execute commands on the data source.

Syntax

connection.Open connectionstring,userID,password,options
parameters Description
connectionstring

Optional. A string value containing information about the connection. The string is composed of a series of parameter=value statements separated by semicolons.

For details on valid settings, please refer to ConnectionString property.

userID Optional. A string value containing the user name to be used when establishing the connection.
password Optional. A string value containing the password to be used when establishing the connection.
options Optional. A ConnectOptionEnum value determines whether this method should return after (synchronously) or before (asynchronously) the connection is established.

instance

DSN-less connection:

<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
%>

DSN-less connection with userID and password (write the conn.open statement on a single line):

<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;
data source=c:/webdata/northwind.mdb;
userID=xxx;
password=yyy"
%>

ODBC Database Connection:

<%
set conn=Server.CreateObject("ADODB.Connection") 
conn.Open "northwind"
%>

ConnectOptionEnum

Constant Value Description
adConnectUnspecified -1 Default value. Synchronously open the connection.
adAsyncConnect 16 Asynchronously open the connection. The ConnectComplete event can be used to determine when the connection is available.