dimanche 10 mai 2015

Performing executenonquery after executereader

I'm working on a program and this is a part of my code:

 If ExecuteREADER("Select ...;") = dr.HasRows Then
        While dr.Read()
            If dr.IsDBNull(0) = False Then
                Dim number As String = dr("number")
                Dim counter As String = dr("counter")
                ExecuteNONQUERY("UPDATE...;") 'NOTE: the number and counter are used in the update command
            End If
        End While
    End If

My problem is, when the ExecuteNONQUERY executes, it returns an error that an open datareader must be closed. But when I close the datareader before executing the ExecuteNONQUERY the datareader cannot read (in the While dr.read part) the other results because datareader is already closed. Any solutions for this? TIA!

Aucun commentaire:

Enregistrer un commentaire