<add name=
"xxx"
connectionString=
"server=10.10.xx.xx;User Id=xxx;password=xxxx;database=xxxx;Port=3306;character set=utf8;"
/>
在web.config中进行编码设置:character set=utf8;
调用存储过程方法:
MySqlCommand cmd = new MySqlCommand(procedureName, con); cmd.CommandType = CommandType.StoredProcedure; MySqlParameter paras1 = new MySqlParameter("@goodsName", MySqlDbType.VarChar); paras1.Value = "test"; cmd.Parameters.Add(paras1); MySqlDataAdapter sda = new MySqlDataAdapter(cmd); DataSet ds = new DataSet(); sda.Fill(ds, "tb_" + procedureName);
关于这个问题,我也查了好的资料,在MySql存储过程的参数中指定编码类型、在my.ini文件中的[mysql],[mysqld]节中配置编码。。。。等都无济于事!最终在数据库连接配置中指定编码才成功!