C# - MySQL - MySql.Data.MySqlClient.MySqlStream.ReadPacket()

本文关键字:ReadPacket MySqlStream Data MySQL MySql MySqlClient | 更新日期: 2023-09-27 17:54:00

我试图通过远程连接连接mysql服务器。

连接字符串为服务器= {IP};数据库= {DB}; uid = {usernname}; pwd ={密码};

        try {
            conn.Open();
            sqlCmd = conn.CreateCommand();
            sqlCmd.CommandText = sqlStr;
            reader = sqlCmd.ExecuteReader(); //->LINE 32
            while(reader.Read()) //Add to library
        } catch (Exception ex) { }
        finally {
           //Close connection and reader
        }

,我得到了这个错误。

08 June 2015 12:58:46 PM   at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
   at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
   at MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int64& insertedId)
   at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
   at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader()
   at ProgramTest.Program.Main() in C:'Projects'ProgramTest'ProgramTest'Program.cs:line 32

我尝试使用Mysql工作台连接并成功接收结果。

我错过的任何导致问题的代码?

提前感谢!

C# - MySQL - MySql.Data.MySqlClient.MySqlStream.ReadPacket()

这个问题在5年前是活跃的。到目前为止,我不确定它是否对你有帮助。但过去两天我也遇到了同样的问题。出现问题的原因是"您传递的参数值太大,超出了它的限制。"

示例:参数'name varchar(15)'和您为名称xxxyyyxxx.....传递的值XXX大于15。尝试将varchar限制从15增加到100,然后再尝试。我希望它能起作用。