Connect to the database through vc ++

Source: Internet
Author: User
1, link to the Access database m_pConn-open (providerMicrosoft. jet. OLEDB.4.0; eclipsedatabasename;, adConnectionUnspecified); 2, link sqldatabase m_pConn-open (driverSQLOLEDB; server127.0.0.1; DataBasedatabasename; UID, PWD, adModeUnknown );

1, link to the Access database m_pConn-open (provider = Microsoft. jet. OLEDB.4.0; Data Sourse = DataBaseName;, adConnectionUnspecified); 2, link sqldatabase m_pConn-open (driver = SQLOLEDB; server = 127.0.0.1; DataBase = databasename; UID =, PWD = ,,, adModeUnknown );

1. Connect to the Access Database

M_pConn-> open ("provider = Microsoft. Jet. OLEDB.4.0; Data Sourse = DataBaseName;", "", adConnectionUnspecified );

2. Link to the SQL database

M_pConn-> open ("driver = SQLOLEDB; server =" 127.0.0.1 "; DataBase =" databasename "; UID =" ", PWD = ""","","", adModeUnknown );

When connecting to the SQL database, the Error is as follows:

1. The link string property is invalid.

The string may be incorrectly written.

2. The database does not exist or the access is denied.

The database does not monitor the corresponding port, or the client connection port is inconsistent with the database. 2. It may be caused by incorrect database settings. In the Configuration Manager, start the TCP/IP protocol and restart SQL server.

3. Unknown error

It may be that an error occurred while accessing PWD from the DAtaBase. 2. catch errors with try and catch.

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.