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

I tried to connect to mysql server using remote connection.

Connection string Server = {IP-}; database = {DB}; UID = {usernname}; PWD = {password};

        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
        }

      

and I got this error.

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

      

I tried to connect using Mysql Workbench and get successful results.

any code i missed causing the problem?

early!

+3


source to share





All Articles