一個開源免費的mysql驅動程序
用法:
using MySQLDriverCS;
MySQLConnection conn = null;
try
{
string connstr = "Data Source=MySQL;Password=root;User ID=root;Location=localhost";
conn = new MySQLConnection(constr);
conn.Open();
string query = "insert into test.dbtable values(10, 'disksidkfsdi', 'asdfaf', 'adsfasdf')";
string tmp = null;
MySQLCommand cmd = new MySQLCommand(query, conn);
for(int i = 0; i < 100000; i++)
{
cmd.ExecuteNonQuery();
}
cmd.Dispose();
conn.Close();
query = "select * from test.dbtable";
MySQLCommand cmd2 = new MySQLCommand(query, conn);
conn.Open();
MySQLDataReader reader = cmd2.ExecuteReaderEx();
while(reader.Read())
{
tmp = reader[0].ToString();
tmp = reader[1].ToString();
tmp = reader[2].ToString();
tmp = reader[3].ToString();
}
conn.Close();
query = "delete from test.dbtable";
MySQLCommand cmd3 = new MySQLCommand(query, conn);
conn.Open();
cmd3.ExecuteNonQuery();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
conn.Close();
}