存储过程代码:ALTER DEFINER=`root`@`localhost` PROCEDURE `GetTestProgramByNameAndVersion`(in _displayName varchar(255),in _version char(10))
BEGIN
   select Id,DisplayName,Version from testpragram where DisplayName=_displayName and Version=_version;
END
ExcuteReader方法代码:        public MySqlDataReader ExcuteReader(string sql, CommandType type, params MySqlParameter[] parameters)
        {
            MySqlConnection conn = null;
            try
            {
                conn = GetOpenedConnection();
                MySqlCommand command = new MySqlCommand(sql, conn);
                command.CommandType = type;
                if (parameters != null)
                {
                    command.Parameters.AddRange(parameters);
                }
                return command.ExecuteReader();
            }
            catch (System.Exception e)
            {
                throw new Exception(e.Message);
            }
        }
C#调用代码:       MySqlParameter param1=new MySqlParameter("?_displayName",MySqlDbType.String,255);
       param1.Value="MySql存储过程测试";
       MySqlParameter param2=new MySqlParameter("?_version",MySqlDbType.String,10);
       param2.Value="0.02";
       MySqlParameter[] parameters = { param1, param2 };
       MySqlDataReader reader = ExcuteReader("GetTestProgramByNameAndVersion", CommandType.StoredProcedure, parameters);
异常信息:
Incorrect string value: '\xB4\xE6\xB4\xA2\xB9\xFD...' for column '_displayName' at row 17各位大侠  帮忙啊!很急的

解决方案 »

  1.   

    检查你的字符集。 在连接字符串中设置一下,或者先在C#中执行一下 set names 'gbk';
      

  2.   

    http://blog.csdn.net/ACMAIN_CHM/archive/2009/05/12/4174186.aspx
    MySQL 中文显示乱码
      

  3.   

    字符集有问题
    show variables  like '%char%';
    设置字符集
    set names gbk;
      

  4.   

    字符集有问题
    show variables  like '%char%';
    设置字符集
    set names gbk;
      

  5.   

    "show full fields from tableName"的执行结果:
    show variables like 'char%'的执行结果:
    数据库连接字符串:(两种连接方式都试过)
    public static string constr = "Data Source=localhost; database=rabbit; user id=root; password=123456; pooling=false;charset=gb2312";
            //public static string constr = "Server=localhost;Database=rabbit;Uid=root;Pwd=123456; CharSet=gb2312";my.ini文件中 default-character-set=gb2312 异常信息:
      Incorrect string value: '\xB4\xE6\xB4\xA2\xB9\xFD...' for column '_displayName' at row 17
      

  6.   

    同样的,我把 gb2312 改成对应 gbk 也试过,还是报出同样的异常。  请多指教,谢谢