“Il existe déjà un lecteur de données ouvert associé à cette connexion qui doit d’abord être fermé.”

la programmation

[ad_1]

Bonsoir les gars, vous écrivez ce code mais il me dit que j’ai un ExecuteReader ouvert.
Pourrais-tu me donner un coup de main
Merci

Ce que j’ai essayé :

VB
        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

EDIT – Code OP de “Solution 1” et Solution supprimée

VB
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]

コメント

Titre et URL copiés