1. From http://prdownloads.sourceforge.net/mysqldrivercs/MySQLDriverCS-n-EasyQueryTools-3.0.18.exe? Download mysqldrivercs.
2. Add mysqldrivercs. dll. To the. NET Component
3. Usage
Create a database link as follows:
Create a database link 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 ();
Insert:
Method prototype:
Public mysqlinsertcommand (
Mysqlconnection Conn,
Object [,] fieldsandvalues,
String table
);
String value = "value ";
Int settingid = 1;
New mysqlinsertcommand (Conn,
New object [,] {"field1", settingid}, {"field2", value }},
"Mysqldrivercs_test"
);
Mysqldrivercs_test is the table name.
Below is the update
Method prototype:
Public mysqlupdatecommand (
Mysqlconnection Conn,
Object [,] fieldsandvalues,
String table,
Object [,] whereparamfields,
String [,] wherenoparamfields
);
Value = "value2 ";
New mysqlupdatecommand (Conn,
New object [,] {"settingvalue", value }},
"Mysqldrivercs_test ",
New object [,] {"settingid", "=", settingid }},
Null
);
Select
Datatable dt = new mysqlselectcommand (Conn,
New String [] {"settingid", "settingvalue "},
New String [] {"mysqldrivercs_test "},
New object [,] {"settingid", "=", settingid }},
Null,
Null
). Table;
String storedvalue = DT. Rows [0] ["settingvalue"]. tostring ();
Below is the delete
New mysqldeletecommand (Conn, "mysqldrivercs_test", new object [,] {"settingid", "=", settingid}, null );
Close link:
Conn. Close ();