using MySqlBulkCopy of MySqlConnector to upload a datatable into MySql. Exception thrown

0

Well i switched to MySqlConnector in order to be able to use its functionality to upload a Datatable into a MySql Table. I'm following their simple example for this function as follow :

  DataTable datatable = Globals.ds.Tables["Song"];

        using (var connection = new MySqlConnection(Globals.connString + "AllowLoadLocalInfile = true;"))
        {
            await connection.OpenAsync();
            var bulkCopy = new MySqlBulkCopy(connection);
            bulkCopy.DestinationTableName = "Song2";
            await bulkCopy.WriteToServerAsync(datatable);
        }

The Song2 table is a empty copy of the Song table that contains 17000 lines and that is feeding the Datatable through a adapter.fill() method (i even did a .FillSchema() before). When i run this, i have 2 exceptions : The first one (the innerexception) is Failed to read the result set. while the second one is "System.Reflection.TargetInvocationException"

Anyone can help ?

Thanks in advance

EDIT : Here is the call stack

  System.Reflection.TargetInvocationException
  HResult=0x80131604
  Message=Une exception a été levée par la cible d'un appel.
  Source=mscorlib
  StackTrace:
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
   at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
   at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)
   at MP3_manager.Program.Main() in C:\Users\Utilisateur\source\repos\MP3-manager\MP3-manager\Program.cs:line 23

  This exception was originally thrown at this call stack:
    MySqlConnector.Utilities.SocketAwaitable.GetResult() in SocketAwaitable.cs
    MySqlConnector.Protocol.Serialization.SocketByteHandler.DoWriteBytesAsync(System.ReadOnlyMemory<byte>) in SocketByteHandler.cs
    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
    System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable<TResult>.ConfiguredValueTaskAwaiter.GetResult()
    MySqlConnector.Protocol.Serialization.ProtocolUtility.WritePacketAsync.__WritePacketAsyncAwaited|8_0(System.Threading.Tasks.ValueTask<int>, byte[]) in ProtocolUtility.cs
    System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
    System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable<TResult>.ConfiguredValueTaskAwaiter.GetResult()
    MySqlConnector.Core.ServerSession.SendReplyAsyncAwaited(System.Threading.Tasks.ValueTask<int>) in ServerSession.cs
    ...
    [Call Stack Truncated]

Inner Exception 1:
MySqlException: Failed to read the result set.

Inner Exception 2:
SocketException: Une connexion existante a dû être fermée par l’hôte distant
c#
mysql
mysql-connector
asked on Stack Overflow Apr 10, 2020 by Sebastien Chemouny • edited Apr 10, 2020 by Sebastien Chemouny

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0