首页 新闻 会员 周边 捐助

mysql乱码问题,命令行支持中文,但是程序读出来之后成了乱码。

0
[已关闭问题] 关闭于 2013-02-22 17:48

见代码

         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   |
+--------------------------+--------+

如图所示

侠梦千年的主页 侠梦千年 | 初学一级 | 园豆:6
提问于:2013-02-21 23:53
< >
分享
所有回答(2)
0

把 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   |
+--------------------------+--------+

侠梦千年 | 园豆:6 (初学一级) | 2013-02-22 09:40
0

目测编码不统一,项目是神马编码,mysql就设置神马编码格式!

 

具体设置最简单的方式就是楼上所述 修改mysql安装目录下的my.ini文件即可!具体google

Beyond-bit | 园豆:2885 (老鸟四级) | 2013-02-22 13:44
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册