见代码
public DataTable GetMySqlDataTable(string sql, ref DataTable table)
{
MySQLCommand cmd = new MySQLCommand(sql,this.DBConn);
MySQLDataAdapter myAdp = new MySQLDataAdapter(cmd);
DataSet ds = new DataSet();
if (this.DBConn.State == ConnectionState.Open)
{
myAdp.Fill(ds);
table = ds.Tables[0];
}
else
{
this.DBConn.Open();
myAdp.Fill(ds);
table = ds.Tables[0];
}
return table;
}
感谢感谢!
mysql> show variables like 'character\_set\_%'
+--------------------------+--------+
| Variable_name | Value |
+--------------------------+--------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | gb2312 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | gb2312 |
| character_set_system | utf8 |
+--------------------------+--------+
如图所示
把 my.ini所有都设置为 gb2312.
+--------------------------+--------+
| Variable_name | Value |
+--------------------------+--------+
| character_set_client | gb2312 |
| character_set_connection | gb2312 |
| character_set_database | gb2312 |
| character_set_filesystem | binary |
| character_set_results | gb2312 |
| character_set_server | gb2312 |
| character_set_system | utf8 |
+--------------------------+--------+
目测编码不统一,项目是神马编码,mysql就设置神马编码格式!
具体设置最简单的方式就是楼上所述 修改mysql安装目录下的my.ini文件即可!具体google