It's not just c.. NET connection to mysql. NET does not have a corresponding driver connection, but odbc connection is used, but this disadvantage is obvious. There is an open source project on sourceforge, specifically
Http://prdownloads.sourceforge.net/mysqldrivercs/MySQLDriverCS-n-EasyQueryTools-3.0.18.exe? Use_mirror = jaist
The method is as follows:
Using MySQLDriverCS;
MySQLConnection conn = new MySQLConnection (new MySQLConnectionString ("localhost", "test", "root", ""). AsString );
Conn. Open ();
If you are using the. net integrated development environment (visual studio.net), enter MySQLDriverCS in the code and then "." To see everything in the MySQLDriverCS namespace.
Below is commond:
MySQLCommand cmd;
Cmd = new MySQLDriverCS. MySQLCommand ("Drop table if exists test. mysqldrivercs_test", conn );
Cmd. ExecuteNonQuery ();
Cmd. Dispose ();
Cmd = new MySQLDriverCS. MySQLCommand ("Create TABLE test. mysqldrivercs_test (" +
"SettingID tinyint (3) unsigned not null auto_increment," +
"SettingValue text," +
"Primary key (SettingID), unique key SettingID (SettingID), KEY SettingID_2 (SettingID)" +
"TYPE = MyISAM COMMENT = ''' MySQL test table '''", conn );
Cmd. ExecuteNonQuery ();
Cmd. Dispose ();
It is easy to use after it is used.