다음을 통해 공유


CDataConnection 클래스

Manages the connection with the data source.

class CDataConnection

멤버

메서드

CDataConnection

생성자입니다. Instantiates and initializes a CDataConnection object.

복사

Creates a copy of an existing data connection.

를 엽니다.

Opens a connection to a data source using an initialization string.

OpenNewSession

Opens a new session on the current connection.

연산자

operator BOOL

Determines whether the current session is open or not.

operator bool

Determines whether the current session is open or not.

operator CDataSource&

Returns a reference to the contained CDataSource object.

operator CDataSource*

Returns a pointer to the contained CDataSource object.

operator CSession&

Returns a reference to the contained CSession object.

operator CSession*

Returns a pointer to the contained CSession object.

설명

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.

참고

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

요구 사항

헤더: atldbcli.h

참고 항목

개념

OLE DB 소비자 템플릿(C++)

OLE DB 소비자 템플릿 참조