Current location - Education and Training Encyclopedia - Education and training - Beida Jade Bird Design Training: Two Methods of Connecting mysql Database with C++?
Beida Jade Bird Design Training: Two Methods of Connecting mysql Database with C++?
Now we are making an interface to operate different databases through different connection strings (database training database authentication).

To use Mysql(Mysql Certification MySQL Training) database, this database has never been used before, and more used are aC++(C++ Training) ess and sqlserver.

Through some information on the internet and my own exploration, the method of connecting mysql and C++ is roughly clear.

Nanjing IT training can be realized in two ways.

The first method is to connect with ADO, and the second method is to connect with mysql's own api function.

The first method can meet my current needs and connect different databases by connecting different strings.

Only mysql, sqlserver, oracle and access are connected for the time being.

For access, because the SQL statement that it creates the table is not compatible with the standard SQL statement, it needs to do some processing, which will not be discussed here for the time being.

The second method can only be used to connect mysql database, but in this case, you don't need to install MyODBC server program.

Either way, you need to install Mysql database first. For the installation method, please refer to "mysql Installation and Some Precautions".

It is best to install Navicatformysql to facilitate the operation of mysql database.

Let's talk about these two methods respectively: (1) Connect MySql database through ADO 1, and connect MySql database through ADO. First of all, install the MyODBC server program.

The version of MyODBC should correspond to the version of MySql, otherwise the database cannot be connected.

I used mysql-5. 1.48-win32.msi and MySQL-connector-odbc-5.1.5-win32.msi respectively.

After installation, click the Start menu-> Settings-> Control panel->; Management tools-> Data source (odbc)->; User DSN-& gt;; Add-> Select MySQLODBC5. 1Driver.

As shown below: Then double-click MySQLODBC5. 1Driver to configure.

After the configuration is completed, you can click Test for the next test (as shown in the figure below). If you can connect, a successful connection dialog box will pop up.