Bug #45305 Reading data from MySql using C# - get MySqlException
Submitted: 3 Jun 2009 13:50 Modified: 20 Jul 2009 10:26
Reporter: Derek Ledbetter Email Updates:
Status: No Feedback Impact on me:
None 
Category:Connector / NET Severity:S1 (Critical)
Version:connector - >net 5.2.6 OS:Windows
Assigned to: Assigned Account CPU Architecture:Any
Tags: C#, Connector/Net, MySQL

[3 Jun 2009 13:50] Derek Ledbetter
Description:
Found an old article that said to update to latest .net connector.  I did that.

I was running a program that reads (one row at a time) from .net C#.  After about 209000 rows, the programs end with the MySqlException.  Fatal error
The message detail is posted below.

Yesterday, I tried to insert into SqlServer 2005.  All was well, until I hit a data Issue.  Today, I have run into this error.

MySql.Data.MySqlClient.MySqlException was unhandled
  Message="Fatal error encountered during data read."
  Source="MySql.Data"
  ErrorCode=-2147467259
  Number=0
  StackTrace:
       at MySql.Data.MySqlClient.MySqlDataReader.Read()
       at UploadShoreTelData.Form1.btnUploadConnect_Click(Object sender, EventArgs e) in C:\Documents and Settings\dledbetter\My Documents\Visual Studio 2005\Projects\UploadShoreTelData\UploadShoreTelData\Form1.cs:line 73
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.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(Int32 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 UploadShoreTelData.Program.Main() in C:\Documents and Settings\dledbetter\My Documents\Visual Studio 2005\Projects\UploadShoreTelData\UploadShoreTelData\Program.cs:line 17
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()

How to repeat:
Create a over 500000 rows in a table on MySql.  This resides on a different server.  I wrote the c# .net program to use the following.  The table is shoreTel (phone system).

            MySqlConnection conn = new MySqlConnection(MySqlConn);
            MySqlCommand myCmd = new MySqlCommand(cmdUpCall, conn);
            conn.Open();

            MySqlDataReader myRdr = myCmd.ExecuteReader(CommandBehavior.CloseConnection);

            //CHCWEB server connection
            SqlConnection chcConn = new SqlConnection(chcwebConn);
            chcConn.Open();

            while (myRdr.Read())
            {
                Int64 iChkID = convertBigInt(myRdr[0].ToString());
                int NbrCount = 0;

-- after awhile the program fails with the error.
[3 Jun 2009 14:55] Derek Ledbetter
Also received the (index out of bounds) - but this just started after rebooting my machine.  I was running this in "debug" in .NET.
[3 Jun 2009 15:16] Derek Ledbetter
this runs for a while - then another ERROR
   at MySql.Data.Types.MySqlDateTime.ParseMySql(String s, Boolean is41)
   at MySql.Data.Types.MySqlDateTime.MySql.Data.Types.IMySqlValue.ReadValue(MySqlStream stream, Int64 length, Boolean nullVal)
   at MySql.Data.MySqlClient.NativeDriver.ReadColumnValue(Int32 index, MySqlField field, IMySqlValue valObject)
   at MySql.Data.MySqlClient.MySqlDataReader.Read()
   at UploadShoreTelData.Form1.btnUploadConnect_Click(Object sender, EventArgs e) in C:\Documents and Settings\dledbetter\My Documents\Visual Studio 2005\Projects\UploadShoreTelData\UploadShoreTelData\Form1.cs:line 76

How can my this statement - while (myRdr.Read()) - produce a 41 when it runs for a while?
[4 Jun 2009 18:12] Derek Ledbetter
More Information - with more errors.

The problem is when I think it is blowing up on a certain record, I rerun the program again and step through (debug) and the error is not there.  

Can someone please explain why the errors are below?  Thanks.

System.IndexOutOfRangeException was unhandled
  Message="Index was outside the bounds of the array."
  Source="MySql.Data"
  StackTrace:
       at MySql.Data.Types.MySqlDateTime.ParseMySql(String s, Boolean is41)
       at MySql.Data.Types.MySqlDateTime.MySql.Data.Types.IMySqlValue.ReadValue(MySqlStream stream, Int64 length, Boolean nullVal)
       at MySql.Data.MySqlClient.NativeDriver.ReadColumnValue(Int32 index, MySqlField field, IMySqlValue valObject)
       at MySql.Data.MySqlClient.MySqlDataReader.Read()
       at UploadShoreTelData.Form1.btnUploadConnect_Click(Object sender, EventArgs e) in C:\Documents and Settings\dledbetter\My Documents\Visual Studio 2005\Projects\UploadShoreTelData\UploadShoreTelData\Form1.cs:line 104
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.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(Int32 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 UploadShoreTelData.Program.Main() in C:\Documents and Settings\dledbetter\My Documents\Visual Studio 2005\Projects\UploadShoreTelData\UploadShoreTelData\Program.cs:line 17
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()

System.FormatException was unhandled
  Message="Input string was not in a correct format."
  Source="mscorlib"
  StackTrace:
       at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
       at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
       at MySql.Data.Types.MySqlDateTime.ParseMySql(String s, Boolean is41)
       at MySql.Data.Types.MySqlDateTime.MySql.Data.Types.IMySqlValue.ReadValue(MySqlStream stream, Int64 length, Boolean nullVal)
       at MySql.Data.MySqlClient.NativeDriver.ReadColumnValue(Int32 index, MySqlField field, IMySqlValue valObject)
       at MySql.Data.MySqlClient.MySqlDataReader.Read()
       at UploadShoreTelData.Form1.btnUploadConnect_Click(Object sender, EventArgs e) in C:\Documents and Settings\dledbetter\My Documents\Visual Studio 2005\Projects\UploadShoreTelData\UploadShoreTelData\Form1.cs:line 104
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.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(Int32 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 UploadShoreTelData.Program.Main() in C:\Documents and Settings\dledbetter\My Documents\Visual Studio 2005\Projects\UploadShoreTelData\UploadShoreTelData\Program.cs:line 17
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
[20 Jun 2009 10:26] Tonci Grgin
Hi Derek and thanks for your report.

Google search reveals many many pages with this problem... I'd start from http://support.microsoft.com/kb/286126, through http://www.issociate.de/board/post/141768/error_-2147467259_(0x80004005).html to http://classicasp.aspfaq.com/general/why-do-i-get-non-database-related-80004005-errors.htm....
This is not MySQL specific, but rather Microsoft specific. Can you provide more info on code and environment? My bet is you're connecting to server, reading and connection somehow drops.
From my side, I did numerous tests like this one (reading hundreds of thousands of rows) and they never failed if connections was stable.
[20 Jul 2009 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".