Error : Fatal error encountered attempting to read the resultset

328
September 20, 2018, at 10:40 AM

I want to insert data in a database table from two other tables

Whenever I run my code, it would return this particular error

An unhandled exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll - Additional information: Fatal error encountered during command execution.

which is pointed at

 cmd.ExecuteNonQuery();

What could be the problem here? Here's my code

private void Merge_Tables_Click(object sender, EventArgs e)
{
    string MergeTables = (@"INSERT INTO exercices (annee,AA,region) 
        SELECT e1.annee,e1.AA,e2.region
        FROM bilan e1 JOIN data e2
        ON e1.siren = e2.siren");
    string serverIp = "127.0.0.1";
    string username = "root";
    string password = "root";
    string databaseName = "altares";
    string dbConnectionString = 
        string.Format("server={0};uid={1};pwd={2};database={3};SslMode=none", 
        serverIp, username, password, databaseName);
    var conn = new MySqlConnection(dbConnectionString);
    conn.Open();
    var cmd = new MySqlCommand(MergeTables, conn);
    cmd.ExecuteNonQuery();
    MessageBox.Show("Table exercices now with data !!");
}

EXPLAN SELECT Results :

Exception Details :

MySql.Data.MySqlClient.MySqlException was unhandled 
  Code=0 
  ErrorCode=-2147467259 
  HResult=-2147467259 
  Message=Fatal error encountered during command execution. 
  Number=0 
  Source=MySql.Data 
  StackTrace: 
       à MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) 
       à MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery() 
       à update_excel.Form1.Merge_Tables_Click(Object sender, EventArgs e) dans C:\Users\BALTI\Documents\Visual Studio 2015\Projects\update-excel\update-excel\Form1.cs:ligne 442 
       à System.Windows.Forms.Control.OnClick(EventArgs e) 
       à System.Windows.Forms.Button.OnClick(EventArgs e) 
       à System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) 
       à System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) 
       à System.Windows.Forms.Control.WndProc(Message& m) 
       à System.Windows.Forms.ButtonBase.WndProc(Message& m) 
       à System.Windows.Forms.Button.WndProc(Message& m) 
       à System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) 
       à System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 
       à System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 
       à System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) 
       à System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) 
       à System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) 
       à System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) 
       à System.Windows.Forms.Application.Run(Form mainForm) 
       à update_excel.Program.Main() dans C:\Users\BALTI\Documents\Visual Studio 2015\Projects\update-excel\update-excel\Program.cs:ligne 19 
       à System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) 
       à System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) 
       à Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 
       à System.Threading.ThreadHelper.ThreadStart_Context(Object state) 
       à System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
       à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
       à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 
       à System.Threading.ThreadHelper.ThreadStart() 
  InnerException:  
       Code=0 
       ErrorCode=-2147467259 
       HResult=-2147467259 
       Message=Fatal error encountered attempting to read the resultset. 
       Number=0 
       Source=MySql.Data 
       StackTrace: 
            à MySql.Data.MySqlClient.MySqlDataReader.NextResult() 
            à MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) 
       InnerException:  
            Code=0 
            ErrorCode=-2147467259 
            HResult=-2147467259 
            Message=Reading from the stream has failed. 
            Number=0 
            Source=MySql.Data 
            StackTrace: 
                 à MySql.Data.MySqlClient.MySqlStream.LoadPacket() 
                 à MySql.Data.MySqlClient.MySqlStream.ReadPacket() 
                 à MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId) 
                 à MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int64& insertedId) 
                 à MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force) 
                 à MySql.Data.MySqlClient.MySqlDataReader.NextResult() 
            InnerException:  
                 HResult=-2146232800 
                 Message=Impossible de lire les données de la connexion de transport : Une tentative de connexion a échoué car le parti connecté n’a pas répondu convenablement au-delà d’une certaine durée ou une connexion établie a échoué car l’hôte de connexion n’a pas répondu. 
                 Source=System 
                 StackTrace: 
                      à System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) 
                      à MySql.Data.MySqlClient.TimedStream.Read(Byte[] buffer, Int32 offset, Int32 count) 
                      à MySql.Data.MySqlClient.MySqlStream.ReadFully(Stream stream, Byte[] buffer, Int32 offset, Int32 count) 
                      à MySql.Data.MySqlClient.MySqlStream.LoadPacket() 
                 InnerException:  
                      ErrorCode=10060 
                      HResult=-2147467259 
                      Message=Une tentative de connexion a échoué car le parti connecté n’a pas répondu convenablement au-delà d’une certaine durée ou une connexion établie a échoué car l’hôte de connexion n’a pas répondu 
                      NativeErrorCode=10060 
                      Source=System 
                      StackTrace: 
                           à System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) 
                           à System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) 
                      InnerException: 

Rent Charter Buses Company
READ ALSO
How to recognize or tag a database based on database information

How to recognize or tag a database based on database information

Imagen you have 10 MySQL databases (on 3 different servers if that matters)5 are meant for development purposes and 5 for production purposes

126
How du dump and restore a MySQL DB with 8 bib BLOBs

How du dump and restore a MySQL DB with 8 bib BLOBs

I could dump my DB with mysqldump -u root -pxxxx chemik > chemiksql But when I want to restore with mysql -u root -pxxxx chemik < chemik

143
MySQL 5.7 for Travis

MySQL 5.7 for Travis

I have MySQL 56 integrated with Travis

166