Connection

ADO Connection Object

 The ADO Connection Object is used to create an open connection to a data source. 

Syntax:-set objConnection=Server.CreateObject("ADODB.connection")

Example:-set connect = Server.CreateObject(“ADODB.connection”)

where connect is a variable of connection object.

Method

Open  The Open method opens a connection to a data source. The connection should be open to execute commands against the data source.  

Syntax:-Objconnection.Open connectionstring, userID, password, options

Where connectionstring is a string value that contains information about the connection, userID is a string value that contains a username for the connection and password is a string value that contains a password for the connection.

Example:-

<%set connect=Server.CreateObject("ADODB.Connection")

DIM CONNECT,
SET CONNECT=SERVER.CreateObject("ADODB.CONNECTION")
STR="PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & SERVER.MapPath("customerdata.MDB")     (NOTE: customerdata.mdb is the name of the database)

CONNECT.Open STR

Close   The Close method is used to close a Connection object if it is open.