是在执行语句前面设置,如:
代码如下:
MySQLCommand mCommand = new
MySQLCommand("set names gb2312", m_Connection);
另一种是直接加在连接字符串里,如:
代码如下:
<add name="connection"
connectionString="server=127.0.0.1;UId=root;PassWord=root;Persist
Security Info=True;database=test;Charset=utf8;"
providerName="MySql" />
我使用的是第二种,非常简单的解决了问题。
c# to MySql 中文乱码,布布扣,bubuko.com
c# to MySql 中文乱码
原文:http://www.cnblogs.com/lycs/p/3610641.html