Udostępnij za pośrednictwem


CDataConnection Class

Manages the connection with the data source.

class CDataConnection

Remarks

CDataConnection is a useful class for creating clients because it encapsulates necessary objects (data source and session) and some of the work you need to do when connecting to a data source

Without CDataConnection, you have to create a CDataSource object, call its OpenFromInitializationString method, then create an instance of a CSession object, call its Open method, then create a CCommand object and call its Open* methods.

With CDataConnection, you only need to create a connection object, pass it an initialization string, then use that connection to open commands. If you plan on using your connection to the database repeatedly, it is a good idea to keep the connection open, and CDataConnection provides a convenient way to do that.

Note

If you are creating a database application that needs to handle multiple sessions, you will need to use OpenNewSession.

Requirements

Header: atldbcli.h

See Also

Concepts

OLE DB Consumer Templates (C+)

OLE DB Consumer Templates Reference

Other Resources

CDataConnection Members