1. Through the ADO connection (in the database connection string for the Chinese seems to be unable to use)
Need to add MySql.Data.dll (available by installing Mysql-connector-net-6.8.3.mis)
Reference MySql.Data.dll
Invocation mode
String connectionstring= "server=localhost;port=3306;database=dbtest;uid=root;pwd=111;"
Mysqlconnection conn = new Mysqlconnection (connectionString))
Conn. Open ();
2. Using ODBC
32-bit MySQL installation Mysql-connector-odbc-5.1.5-win32.msi
64-bit MySQL installation Mysql-connector-odbc-5.1.12-winx64.msi
If it is a 32-bit operating system, you can add the DSN directly in the ODBC Administrator, if the 64-bit operating system, the MySQL version is 64-bit can be added directly dsn,mysql is 32-bit, you need to open C:\Windows\SysWOW64\ Odbcad32.exe to add a DSN. After you add it, you can add tests in the Server Explorer, vs-> view, to see if it is successful.
32-bit ODBC configuration Manager
String constr = "Driver={mysql ODBC 5.1 Driver}; Server=localhost; Port=3306;database= Chinese; User=root; password=111;option=3; ";
OdbcConnection conn = new OdbcConnection (CONSTR);
Conn. Open ();
3. Use MySQLDriverCS.dll (not available on 64-bit systems, no 64-bit DLLs available temporarily)
Direct reference to MySQLDriverCS.dll (can be found directly online)
Using Mysqldrivercs;
Mysqlconnection conn = new Mysqlconnection (new mysqlconnectionstring ("localhost", "Test", "root", ""). asstring);
Conn. Open ();