Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

Connecting to a Data Source

An ODBC data source is a specific set of data, the information required to access that data, and the location of the data source, which can be described using a data-source name. From your program's point of view, the data source includes the data, the DBMS, the network (if any), and ODBC.

To access data provided by a data source, your program must first establish a connection to the data source. All data access is managed through that connection.

Data-source connections are encapsulated by class CDatabase. When a CDatabase object is connected to a data source, you can:

  • Construct recordsets, which select records from tables or queries.

  • Manage transactions, batching updates so all are committed to the data source at once (or the whole transaction is rolled back so the data source is unchanged) — if the data source supports the required level of transactions.

  • Directly execute Structured Query Language (SQL) statements.

When you finish working with a data-source connection, you close the CDatabase object and either destroy it or reuse it for a new connection. For more information about data-source connections, see Data Source (ODBC).

Community Additions

ADD
Show:
© 2015 Microsoft