Net packets out of order

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
Jayel
Posts: 8
Joined: Wed 27 Dec 2006 17:15

Net packets out of order

Post by Jayel » Wed 27 Dec 2006 17:26

Hello,

from time to time I get this error

Net packets out of order: received[0], expected[2]

Here is de sub where the error occurs.

Code: Select all

    Private Function GetHostname(ByVal locIp As String) As String
        Dim x As Integer = 0
        Dim MyConn As New MySqlConnection
        Try
            MyConn = New MySqlConnection
            With MyConn
                .Host = pubMySQLServerIP
                .Port = 3306
                .Password = "pissewit"
                .Database = "dbHosts"
                .UserId = "root"
                .Open()
            End With
        Catch ex As MySqlException
            MsgBox(ex.Code & " " & ex.ErrorCode & " " & ex.Message)
            End

        End Try

        Dim mySelectQuery As String = "SELECT hostname from tblhosts where ip = '" & locIp & "'"
        Dim myResult As String = ""
        Dim myCommand As New MySqlCommand(mySelectQuery, db)
        Dim myReader As MySqlDataReader = myCommand.ExecuteReader()
        If myReader.HasRows Then
            myResult = myReader.GetString(0).ToString()
        End If
        ' <always call Close when done reading.
        myReader.Close()
        myCommand.Dispose()
        myCommand = Nothing
        MyConn.Close()
        MyConn = Nothing
        Return myResult
    End Function
What is wrong here ?

Thanks in advance !

[email protected]
Posts: 38
Joined: Tue 07 Mar 2006 17:13

Post by [email protected] » Wed 27 Dec 2006 18:28

In this line:

Dim myCommand As New MySqlCommand(mySelectQuery, db)

Where do you declare "db" in your code? If its a connection declared outside the scope of this function then the error is probably a result of reusing the connection for multiple commands.

There are other threads with the same error message (I know because I once had the same problem) and the solution was to create connections for each instance so that I didn't "step on the toes" of either. Try changing your code to:

Dim myCommand As New MySqlCommand(mySelectQuery, myConn)

and see if you still have the problem.

Just a thought...

jh

Alexey
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Post by Alexey » Fri 29 Dec 2006 07:36

Jayel, have you resolved the problem?

Jayel
Posts: 8
Joined: Wed 27 Dec 2006 17:15

Post by Jayel » Sat 30 Dec 2006 10:13

Yes,

Thanks.
I had db declare as a public connection, I forgot tp change it in "Myconn".
Now I have tried several times and It doesn't crash anymore.
But why can't I declare the connection public and use it in various functions or subs ?
I did that with the mysql connector and that works just fine !!

Alexey
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Post by Alexey » Fri 05 Jan 2007 13:24

I seems that you had DataDirects opened simultaneosly or something like that.

Post Reply