<ADODB_Connection>.Open

<< Click to Display Table of Contents >>

Navigation:  ThinBASIC Modules > ADODB > ADODB Module Classes > ADODB_Connection > ADODB_Connection Methods >

<ADODB_Connection>.Open

 

Description

 

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

 

Syntax

 

n = <ADODB_Connection>.Open [(sConnectionString [, sUserId [, sPassword [, Options]]])]

 

Returns

 

Number: Connection State. See <ADODB_Connection>.State for possible values.

 

Parameters

 

Name

Type

Optional

Meaning

sConnectionString

String

Yes

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

See the ConnectionString property for details.

sUserId

String

Yes

A String value that contains a user name for the connection

sPassword

String

Yes

A String value that contains a password for the connection

sOptions

Numeric

Yes

An OptionEnum value that determines whether this method should return after or before the connection is established.

 

Possible values:

%adConnectUnspecified        Default. Opens the connection synchronously (after).

%adAsyncConnect                Opens the connection asynchronously (before).

 

 

 

Remarks

 

Use <ADODB_Connection>.Close when finished to use a connection

 

Restrictions

 

See also

 

Examples

 

String sConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & APP_SourcePath & "Biblio.mdb"

 

'---Declare a new pConnection variable

Dim pConnection As ADODB_CONNECTION

'---Instantiate it as new connection

pConnection = New ADODB_CONNECTION '[(sConn)]

'---Open indicating connection string

pConnection.Open(sConn)

 

Alternative

 

'---Declare a new pConnection variable and instantiate it in one line

Dim pConnection As New ADODB_CONNECTION '[(sConn)]

'---Set connection string

pConnection.ConnectionString = sConn

'---Open connection. Connection string is taken from ConnectionString property

pConnection.Open