Summary

This chapter has introduced the Connection object -- the first of the nine major components of ActiveX Data Objects. You have learned how to establish connections with any type of OLE DB data provider. The following list summarizes key points:

  • You can create a Connection object either explicitly within your own code, or implicitly, through instantiation of a Recordset or Command object.

  • Each Connection object represents a single unique connection to a particular OLE DB data source through a data provider, both of which you have specified in a connection string.

  • With the Connection object, you can execute commands against the associated data source. There are three types of commands that can be executed: a SQL statement, a stored procedure, or a parameterized query. In addition, you can open a simple table or pass a data provider-specific string to the particular data provider, which will provide its own analysis and resultset.

  • The Connection object controls the utilization of transaction management through three methods: BeginTrans, CommitTrans, and RollbackTrans. Transactions are used to manage the integrity of one or multiple data sources when data is manipulated. Like If...Then statements, transactions can be nested.

  • You can use the Connection object to obtain information about the structure of a given data source with the use of the OpenSchema method. This information can be helpful when querying for table, procedure, or index names.

The next chapter of this book, Chapter 5, explains how to manipulate and read data that is stored in record form, each of which is a collection of fields.

Get ADO: ActiveX Data Objects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.