Open Method (Connection) ADO

Opens a connection to a data source.

Applies To

Connection

Required Files

msado15.dll
VC: adoint.h, adoid.h

Syntax

connection.Open ConnectionString, UserID, Password

ConnectionString Optional. A String containing connection information. See the ConnectionString property for details on valid settings.
UserID Optional. A String containing a user name to use when establishing the connection.
Password Optional. A String containing a password to use when establishing the connection.

Remarks

Using the Open method on a Connection object establishes the physical connection to a data source. After this method successfully completes, the connection is live and you can issue commands against it and process results.

Use the optional ConnectionString argument to specify a data source name (DSN) or a detailed connection string containing a series of argument = value statements separated by semicolons. If the argument contains an equal sign ("="), ADO assumes you are providing a connection string rather than a DSN. The ConnectionString property automatically inherits the value used for the ConnectionString argument. Therefore, you can either set the ConnectionString property of the Connection object before opening it, or use the ConnectionString argument to set or override the current connection parameters during the Open method call.

If you pass user and password information both in the ConnectionString argument and in the optional UserID and Password arguments, the results may be unpredictable; you should only pass such information in either the ConnectionString argument or the UserID and Password arguments.

When you have concluded your operations over an open Connection, use the Close method to free any associated system resources. Closing an object does not remove it from memory; you may change its property settings and use the Open method to open it again later. To completely eliminate an object from memory, set the object variable to Nothing.

Examples

Open and Close Methods Example (VB)

© 1997 Microsoft Corporation. All rights reserved. Terms of Use.