Welcome to the CC ++ programming community forum, and interact with 3 million technical staff. Now we are working on an interface to operate different databases through different connection strings. Mysql databases are used. This database has never been used before. There are many access and sqlserver databases. Through some information on the Internet and my own exploration, I have roughly understood how C ++ connects to mysql
Welcome to the C/C ++ programming community forum, and interact with 3 million technical staff> access is now working on an interface to operate different databases through different connection strings. Mysql databases are used. This database has never been used before. There are many access and SQL server databases. Through some information on the Internet and my own exploration, I have roughly understood how C ++ connects to mysql
Welcome to the C/C ++ programming Community Forum and interact with 3 million technical staff> enter
Now we are working on an interface to operate different databases through different connection strings. Mysql databases are used. This database has never been used before. There are many access and SQL server databases. Through some information on the Internet and my own exploration, I have roughly understood how C ++ connects to mysql. You can achieve this in two ways.
The first method is to connect using ADO,
The second method is to use mysql's own api functions for connection.
The first method can achieve my current needs by connecting different strings to connect different databases. Currently, only mysql, sqlserver, oracle, and access are connected. For access, because the SQL statement used to create a table is not compatible with standard SQL statements, some processing is required. The second method can only be used for mysql database connections. However, you do not need to install the MyODBC server program in this method.
No matter which method is used, you must first install the Mysql database. For the installation method, see "mysql installation and some precautions ". It is best to install a Navicat for mysql to facilitate operations on the mysql database. The two methods are described as follows:
(1) connecting to the MySql database through ADO
1. to connect to the MySql database through ADO, first install the MyODBC server program.
The MyODBC version must match the MySql version. Otherwise, the database cannot be connected. The versions I use are mysql-5.1.48-win32.msi and mysql-connector-odbc-5.1.5-win32.msi.
After installation, choose Start> Settings> Control Panel> Administrative Tools> data source (ODBC)> User DSN> Add> select MySQL ODBC 5.1 Driver. For example:
Double-click MySQL ODBC 5.1 Driver. After configuration, click Test to perform the Test (for example). If the connection is successful, the connection successful dialog box is displayed.
Data Source Name in: the content is the value corresponding to the DSN in the code.
[1] [2] [3] [4]