‘Ya hay un lector de datos abierto asociado con esta conexión que debe cerrarse primero.’

programación

[ad_1]

Buenas noches chicos, están escribiendo este código pero me dice que tengo un ExecuteReader abierto.
Me puedes dar una mano
Gracias

Lo que he probado:

V.B.
        Dim namecontr As String
        Dim rdr3 As Object

        Dim cmd3 As New MySqlCommand("Select s01_name_contr  from s01_tpcontratti where id=" & rdr.Item(2), cnnmysql)
        rdr3 = cmd3.ExecuteReader
        rdr3 = cmd3.ToString   ' 03/12 ore 17:25 capire perche non mi funziona si blocca 29/12 non ancora sbloccato
        'cmd3.Dispose()

        '  rdr3.Read()



        If rdr3.HasRows = True Then
            namecontr = rdr3.Item(0).ToString
        End If

        Dim data As Date = CDate(rdr.Item(3).ToString)
        grid_contratto.Rows.Add(rdr(0).ToString, rdr(2).ToString, namecontr, "stocazzo", data.ToShortDateString)
        '   rdr3.close()
    Loop
    rdr.Close()

    'cnnmysql.Clone()

End Sub

EDITAR: código OP de la “Solución 1” y Solución eliminada

V.B.
Private Sub carica_grigliacontratti(id As String)
    '  Call connetti_mysql()
    ' cnnmysql.Open()

    If CInt("0" & id) = 0 Then Exit Sub
    Dim sql As String
    Dim rdr As Object
    ' Dim rdr2 As Object
    '  grspecialisti.Rows.Clear()


    sql = "Select * from a01_contratti where a01_cliente=" & id


    Dim cmd1 As New MySqlCommand(sql, cnnmysql)

    rdr = cmd1.ExecuteReader()
    cmd1.Dispose()


    If rdr.HasRows = False Then
        rdr.Close()

        Exit Sub
    End If
    sistema_grcerca()

    '    Dim perc As Long = 0
    '        Dim volte As Integer = 0w
    cnnmysql.Clone()
    grid_contratto.Rows.Clear()

    Do While rdr.Read

        Dim namecontr As String
        Dim rdr3 As Object

        Dim cmd3 As New MySqlCommand("Select s01_name_contr  from s01_tpcontratti where id=" & rdr.Item(2), cnnmysql)
        rdr3 = cmd3.ExecuteReader
        rdr3 = cmd3.ToString   ' 03/12 ore 17:25 capire perche non mi funziona si blocca 29/12 non ancora sbloccato
        'cmd3.Dispose()

        '  rdr3.Read()



        If rdr3.HasRows = True Then
            namecontr = rdr3.Item(0).ToString
        End If

        Dim data As Date = CDate(rdr.Item(3).ToString)
        grid_contratto.Rows.Add(rdr(0).ToString, rdr(2).ToString, namecontr, "stocazzo", data.ToShortDateString)
        '   rdr3.close()
    Loop
    rdr.Close()

    'cnnmysql.Clone()

End Sub

[ad_2]

コメント

Título y URL copiados