Cdatabase OPEN function usage

Source: Internet
Author: User
Tags cursor library

To establish a connection with the data source, you must first construct a cdatabase object and then call the open

The member function. OPEN function is responsible for establishing a connection, and its declaration is

Virtual bool open

(

Lpctstr lpszdsn,

Bool bexclusive = false,

Bool breadonly = false,

Lpctstr lpszconnect = "ODBC ;",

Bool busecursorlib = true

);

Throw (cdbexception, cmemoryexception );

Parameter description:

Lpszdsn specifies the data source name, which can also be included in the lpszconnect parameter. At this time, lpszdsn must be null. If the data source name is not provided in the function and lpszdsn is null, a Data Source dialog box is displayed. You can select a data source in the dialog box.

Bexclusive indicates whether the data source is exclusive. Because the current version of the class library does not support exclusive mode, the value of this parameter should be false, which indicates that the data source is shared.

If breadonly is true, the connection to the data source is read-only.

Lpszconnect specifies a connection string that contains information such as the data source name, User Account (ID), and password. "ODBC" in the string indicates that you want to connect to an ODBC data source.

If the value of busecursorlib is true, the cursor library is loaded; otherwise, the cursor library is not required for snapshots, And the cursor library is not required for dynamic sets.

Reference code:

# Include "afxdb. H"

Cdatabase m_db;

M_db.open (null, false, false, _ T ("ODBC; uid = sa; Pwd = sa"), true); // connect to the database

To remove from a data source, you can call the close function. After the disconnection, you can call the OPEN function again to establish a new connection. Call isopen to determine whether a connection exists. Call getconnect to return the current connection string.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.