The first method is to use ADO connection,
The second method is to use mysql's own api function to connect.
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) connecting MySql database through ADO.
1. To connect MySql database through ADO, you must first 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 in the figure 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.