Page 1 of 1

Aborted connection (Got an error reading communication packet)

Posted: Fri 28 Apr 2006 00:02
by JBDev
[/code]Get this MySQL error in the Application event viewer for the following console application. (Aborted connection - got an error reading communication packet)[/quote]

Code: Select all

Imports CoreLab.MySql
Imports System.IO

Module DataTable

    Sub Main()
        Dim strFileName As String = "C:\Export.txt"

        Dim intLoop As Integer
        Dim strString As String
        Dim strSql As String

        ' Delete the file if it exists.
        If File.Exists(strFileName) Then
            File.Delete(strFileName)
        End If

        'Create the file.
        Dim objFileOpen As FileStream = File.Create(strFileName)
        Dim objFileWrite As StreamWriter = New StreamWriter(objFileOpen)

        'Build table
        strSql = "SELECT AssociateNumber, CardNumber, NameFirst, NameLast, Department, JobCode FROM Associate"
        Dim dtAssociate As MySqlDataTable = New MySqlDataTable(strSql, "Host=localhost;Port=3306;User ID=root;Password=$4JBDev@ds;Database=Express")
        Try
            dtAssociate.Active = True
            For intLoop = 0 To dtAssociate.Rows.Count - 1
                strString = dtAssociate.Rows(intLoop)(0).ToString.PadLeft(12) & "," & _
                            dtAssociate.Rows(intLoop)(1).ToString.PadLeft(2, "0") & "," & _
                            dtAssociate.Rows(intLoop)(2).PadRight(14) & "," & _
                            dtAssociate.Rows(intLoop)(3).PadRight(20) & "," & _
                            dtAssociate.Rows(intLoop)(4).PadRight(10) & "," & _
                            dtAssociate.Rows(intLoop)(5).PadRight(6)
                objFileWrite.WriteLine(strString)
            Next
        Finally
            dtAssociate.Active = False
        End Try
        objFileWrite.Close()
    End Sub

End Module
[/code]

Posted: Fri 28 Apr 2006 06:32
by Alexey
Add Pooling=false attribute to the ConnectionString argument.
We also recommend to use MySqlDataReader instead of MySqlDataTable in order to not store all fetched records in the working memory.

Posted: Sat 09 May 2009 05:34
by jackkenyon
To Alexey

I am also getting these errors intermittently from mysql server. I have set Connection.Pooling=FALSE. Is this the same thing?
I also found a reference saying that components can only be used by one thread. Does this include the TMySqlUniProvider and the TUniConnection components?

thanks

Posted: Wed 13 May 2009 16:00
by Shalex
We recommend you to use the separate TUniConnection object for every thread.