Bug #87549 Error datareader
Submitted: 25 Aug 2017 18:35 Modified: 24 Jan 2018 10:29
Reporter: Giuseppe Chiodaroli Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / NET Severity:S3 (Non-critical)
Version:5.6.37 OS:Microsoft Windows
Assigned to: CPU Architecture:Any

[25 Aug 2017 18:35] Giuseppe Chiodaroli
Description:
I used a dataset with a one connection into mysql database.
Some time I recived this error:

"There is already an open DataReader associated with this Connection which must be closed first."

but I not use the datareader but I used dataset, and I detroyed the dataset object every time I terminated the read data.

My version of .NET conntecto is 6.3.5 and I use a windows 7 64bit, but the same problem I recived with win10 64 bit.

How to repeat:
Create a connection with a database and use ado,net dataset
[28 Aug 2017 6:10] Chiranjeevi Battula
Hello Giuseppe,

Thank you for the report.
Could you please provide repeatable test case (exact steps/sample project, connection string,create tables statements etc. - please make it as private if you prefer) to confirm this issue at our end?

Thanks,
Chiranjeevi.
[28 Aug 2017 7:02] Giuseppe Chiodaroli
This is an example code for replace a error.
But the strange thing is that it does not always happen to the mistake.

I tried to create a cycle that every tot seconds would perform the select but on 20 iterations the error has only appeared 4 times.

Imports MySql.Data.MySqlClient

Public Class clsDataBase
    Public Structure DataBaseType
        Public Const Mysql = "mysql"
        Public Const SqlSever = "sqlserver"
    End Structure

    Public MysqlConn As MySqlConnection
    Public cmdTS As MySqlCommand

    Function ConnettiDataBase(Host As String, DataBase As String, Port As Integer, User As String, Password As String, DataBaseType As String)
        'Dim TipoDataBase = "mysql"
        Select Case DataBaseType.ToString.ToLower
            Case "mysql"

                MysqlConn = New MySqlConnection()
                MysqlConn.ConnectionString = "server=" & Host & ";" & "user id=" & User & ";" & "password=" & Password & ";" & "database=" & DataBase & ";Port=" & Port
                Try
                    MysqlConn.Open()
                    Return 0
                Catch myerror As MySqlException
                    Return Err.Number & " - " & Err.Description
                    MysqlConn.Dispose()
                Finally

                End Try

                'Case "sqlserver"

        End Select
        Return 0
    End Function
end Class

--- This is a code present into a formload event
Imports MySql.Data.MySqlClient
Public Class frmGrafico
	Public DataBase As New clsDataBase
	Private Sub MDIParent1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
		Ret = DataBase.ConnettiDataBase("127.0.0.1", "monitor", 3306, "user", "password", DataBase.DataBaseType.Mysql)
		If Ret <> "0" Then
			VisualizzaMsg(2, "Connessione Database", "Errore durante la connessione.")
			frmSetup.ShowDialog()
			Exit Sub
		End If
	end sub

--- This is a code present into a timer event for extracting the data from table

	Private Sub btnRicarica_Click(sender As Object, e As EventArgs) Handles btnRicarica.Click
        ssql = "select payload from tab_Data where DataTopic ='/weather/ext/temp' order by iddata limit 10"
        cmbNodo.Items.Clear()
        Try
            Dim adapter As MySqlDataAdapter = New MySqlDataAdapter(ssql, DataBase.MysqlConn)
            Dim Dati As DataSet = New DataSet
            adapter.Fill(Dati, "Dati")
            For Each Dr As DataRow In Dati.Tables("Dati").Rows
                Dato = Dr("payload")
                cmbNodo.Items.Add(Dato)
            Next
            adapter.Dispose()
            Dati.Dispose()
        Catch ex As Exception
            ---- Write log error
        End Try
	end sub
end class
[24 Jan 2018 10:29] Chiranjeevi Battula
Hello Giuseppe,

Thank you for the feedback.
I could not repeat the issue at our end using with Visual Studio 2017, Connector/NET 6.10.5 version.
If you can provide more information, feel free to add it to this bug and change the status back to 'Open'.

Thank you for your interest in MySQL.

Thanks,
Chiranjeevi.