C # connection to MySQL _c# tutorial

Source: Internet
Author: User
Not just C #, it's actually said. NET under the connection with MySQL, if generally, because. NET does not have the corresponding drive connection and its corresponding, is uses the ODBC connection, but this kind of malpractice is obvious, has an open source project in the SourceForge, the concrete download address is
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 your code and then enter a "." You can see all the things in the Mysqldrivercs namespace.

Here 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 use, found that it is more useful

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.