C#操作mysql问题
string myConnstr = "Server=localhost:3306;User ID=root;Password=;Database=test;CharSet=utf8;";
MySQLConnection conn = null;
conn = new MySQLConnection(myConnstr);
conn.Open();
MySQLCommand commn1 = new MySQLCommand();
commn1.CommandText = sqlstr;
commn1.ExecuteNonQuery();
conn.Close();
报错:MySQLDriverCS Exception: Connection must be valid and open.
大侠告诉我下怎么解决 谢谢
我之前用的是
conn = new MySQLConnection(new MySQLConnectionString("localhost", "test", "root","").AsString);
MySQLCommand commn = new MySQLCommand("set names utf8", conn);
但是插入进去的是乱码
我的mysql是utf8 的