C # connection to mysql

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.