Connection between c sharp and mysql

  • 2020-05-05 11:43:40
  • OfStack

It's not just c#, it's actually the connection to mysql under.NET, if in general, because.NET has no corresponding driver connection, it's an odbc connection http://prdownloads.sourceforge.net/mysqldrivercs/MySQLDriverCS-n-EasyQueryTools-3.0.18.exe?use_mirror=jaist
Here's how :
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), type MySQLDriverCS in your code and then type ". "to see everything in the MySQLDriverCS namespace.

The following 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();

After using
, I found it still works well

Related articles: