以前我使用sql server 2005作为我的网站数据库,一切运作良好.
现在我已经改为
MySql server 5.5数据库,因为它是开源的.
我使用Navicat Premium将我的数据从sql server传输到MysqL.我使用MysqL workbench和navicat来管理我的数据库.当我声明与MysqL数据库的连接时出现问题.这是我的代码:
MysqLCommand cmdselect;
MysqLConnection conNDB;
MysqLDataReader Mydtr;
string server = "localhost";
string database = "maindb";
string uid = "root";
string password = "abc123";
string strCon = "SERVER=" + server + ";" + "DATABASE=" +
database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";
string strSelect = "SELECT * FROM announcement";
conNDB = new MysqLConnection(strCon);
conNDB.Open();
cmdselect = new MysqLCommand(strSelect,conNDB);
Mydtr = cmdselect.ExecuteReader();
rptAnnounce.DataSource = Mydtr;
rptAnnounce.DataBind();
Mydtr.Close();
conNDB.Close();
已经设置了对MysqL.Data的引用.在这里我收到此错误消息:
Exception Details:
MysqL.Data.MysqLClient.MysqLException:
Variable ‘character_set_client’ can’t
be set to the value of ‘utf16’
Error message stated this error occurs during connection.Open();
当我继续刷新错误页面时,我有时会收到另一个错误.就这个:
Exception Details: MysqL.Data.MysqLClient.MysqLException: Expected end of data packet
Error message stated this error occurs during Mydtr = cmdselect.ExecuteReader();
我是MysqL的新手.我不知道这是什么问题.我想这个问题来自数据库的设置或数据,而不是我的源代码.
有谁知道解决方案?非常感谢您的帮助.我一直在尝试4天但无法解决.