首页 > ASP.NET, DataBase > asp.net连接mysql字符校对不匹配

asp.net连接mysql字符校对不匹配

2008年12月27日
936 views 评论 发表评论

今天升级了一个原来由Visual Studio 2002开发的一个asp.net+mysql项目,升级到.net framework 2.0后,编译没有任何错误,但居然不能运行了,提示信息如下:

Illegal mix of collations (latin1_swedish_ci,IMPLICIT), (gb2312_chinese_ci,COERCIBLE), (gb2312_chinese_ci,COERCIBLE)

解决办法如下:
1,修改数据库/表/字段的编码.
2,执行之前加上set names latin1;
3,更改my.ini的init-connect=” latin1″(没有则加上).
4,查询时加上强制字符编码转换
   select * from table where name = ‘xxx’ COLLATE latin1_swedish_ci

ASP.NET, DataBase

  1. 目前还没有任何评论.
  1. 目前还没有任何 trackbacks 和 pingbacks.

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word