title: Fatal error encountered during command execution
body: <p>when i execute stored procedure on remote mysql from my c# code i get the generic error:
  "Fatal error encountered during command execution"
  total details:</p>
  
  <pre><code>MySql.Data.MySqlClient.MySqlException: Fatal error encountered during command execution. ---&gt;  MySql.Data.MySqlClient.MySqlException: Fatal error encountered attempting to read the resultset. ---&gt;  MySql.Data.MySqlClient.MySqlException: Reading from the stream has failed.
  ---&gt;  System.IO.EndOfStreamException: Attempted to read past the end of the stream.    at MySql.Data.MySqlClient.MySqlStream.ReadFully(Stream stream, Byte[] buffer, Int32 offset, Int32 count)    at MySql.Data.MySqlClient.MySqlStream.LoadPacket()
  --- End of inner exception stack trace ---    at MySql.Data.MySqlClient.MySqlStream.LoadPacket() at MySql.Data.MySqlClient.MySqlStream.ReadPacket() at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32&amp; affectedRow, Int32&amp; insertedId)    at MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32&amp; affectedRows, Int32&amp; insertedId)    at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId)    at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
  --- End of inner exception stack trace ---    at MySql.Data.MySqlClient.MySqlDataReader.NextResult() at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)    --- End of inner exception stack trace ---    at MySql.Data.MySqlClient.MySqlCommand.EndExecuteNonQuery(IAsyncResult asyncResult
  </code></pre>
  
  <p>)</p>
  
  <p>my c# code:</p>
  
  <pre><code> internal void InsertUpdateMySql(string connectionstring, string storedprocedure)
      {
          string sLog = "internal void InsertUpdateMySql(string connectionstring, string storedprocedure)";
          MySqlConnection conn = new MySqlConnection();
          int rowsAffected = 0;
          try
          {
              if (!string.IsNullOrEmpty(storedprocedure) &amp;&amp; !string.IsNullOrEmpty(connectionstring))
              {
                  conn.ConnectionString = connectionstring;
                  MySqlCommand cmd = new MySqlCommand(storedprocedure);
                  cmd.Connection = conn;
                  conn.Open();
                  IAsyncResult myResult = cmd.BeginExecuteNonQuery(null, null);
                  SetProgressinRichText("In progress\n");
                  while (!myResult.IsCompleted)
                  {
                      SetProgressinRichText(".");
                  }
                  rowsAffected = cmd.EndExecuteNonQuery(myResult);
              }
          }
          catch (MySqlException ex)
          {
              this.service.WriteToLog(source, sLog + "\n" + ex.Message + "\n" + ex.StackTrace);
          }
          catch (Exception ex)
          {
              this.service.WriteToLog(source, sLog + "\n" + ex.Message + "\n" + ex.StackTrace);
          }
          finally
          {
              if (conn.State != System.Data.ConnectionState.Closed)
                  conn.Close();
          }
      }
  </code></pre>
  
  <p>the sp same like that:</p>
  
  <pre><code>DELIMITER $$
  
  
  CREATE  PROCEDURE `SPInsertUpdateCity`( in SP_CityName VARCHAR(100) charset utf8, in SP_CitySynonyms varchar(100) charset utf8, in SP_CityNumberPostOffice varchar(100)) BEGIN   if(not exists(select CityID from city where CityName = SP_CityName)) then      insert into city(CityName, CityNumberPostOffice) values(SP_CityName, SP_CityNumberPostOffice);      insert into citysynonym (CityID, CitySynonymName) values(Last_insert_id(),SP_CitySynonyms);      else if(not exists( select  CitySynonymID from    citysynonym where   CitySynonymName = SP_CitySynonyms)) then    
                  insert into citysynonym (CityID, CitySynonymName) values((select cityid from city where CityName=SP_CityName), SP_CitySynonyms);     end if;    end if; END$$
  
  DELIMITER ;
  </code></pre>
  
  <p>the connection string:</p>
  
  <pre><code>Server=XXXX; Port=XXXX; Database=XXXX; Uid=XXXX;Pwd=XXXX;charset=utf8;default command timeout=7200;
  </code></pre>
  
  <p>but when i exceute that on local mysql it success as well!
  for remote mysql i tryied to send little data (3 records) and it executed successfully, but for large data (1500 records) the execute is failed</p>