Error: "There is already an open DataReader associated with this Connection ....." (VB
Loop:
"There is already an open DataReader associated with this Connection which must be closed first".
-- CODE -
Private Sub PrepareSingleLedger(ByVal myFirmID As Long, ByVal myDate1 As Date, ByVal myDate2 As Date, ByVal myParty
As String)
Dim qSL As String = "Select PDate, FirstParty, ItemName, Rate, Qty, SecondParty, Commission, Remark, TranID From
PParty_Transac Where FirstParty = '" & myParty & "' or SecondParty = '" & myParty & "' and FirmID = " & myFirmID & " and PDate
between #" & Format(myDate1, "dd-MMM-yyyy") & "# and #" & Format(myDate2, "dd-MMM-yyyy") & "# Order By PDate"
Dim cmdSL As New OleDb.OleDbCommand(qSL, CN)
Dim drList As OleDb.OleDbDataReader
drList = cmdSL.ExecuteReader
While drList.Read = True
If IsDBNull(drList(1)) = False Then
If drList(1) = myParty Then
Dim qP1 As String = "Insert into tempSingleLedger (partyname) Values(drlist(1))" ' " & drList(0) & ",'S'," & drList(5) & "," &
drList(2) & "," & drList(3) & "," & drList(4) & "," & drList(6) & "," & drList(7)
Dim ins As New OleDb.OleDbCommand(qP1, CN)
ins.ExecuteNonQuery()
End If
End If
End While
drList.Close()
End Sub
-- CODE --
Here is description of what I want to do with the above code:
(1) qSL query is executed and its result is stored in the DataReader "drList".
(2) Now in the While Loop I want to check whether the FirstParty in qSL query = myParty. If that is the case the Insert Query written is to
be executed. "myParty" is the name of the Firm that is passed as argument to this routine.

