初涉Asp.net,用VS2008连接MySql,
在用到查询语句时出现上述错误,经过一步步探究发现是查询语句字符编码不一致问题。但我不知道两个程序怎样设置字符编码。
看到一篇回复:
mysql> show variables like '%set%';
+--------------------------+----------------------------------------------------
-----+
| Variable_name | Value
|
+--------------------------+----------------------------------------------------
-----+
| auto_increment_offset | 1
|
| character_set_client | utf8
|
| character_set_connection | utf8
|
| character_set_database | utf8
|
| character_set_filesystem | binary
|
| character_set_results | utf8
|
| character_set_server | utf8
|
| character_set_system | utf8
|
| character_sets_dir | C:\Program Files\MySQL\MySQL Server 5.0\share\chars
ets\ |
+--------------------------+----------------------------------------------------
-----+
9 rows in set (0.00 sec)
对比一下发现我的 character_set_server=latin1
于是在My.ini中加入一行
character_set_server=utf8
再重启mysql就可以正常查询了