C
C#8mo ago
jami1217

✅ There is already an open DataReader associated with this Command which must be closed first

I'm currently developing a Point Of Sale software in winforms c#. While working on cash management module I encountered such issue: There was an issue with insert into TblCashOutReportItem: There is already an open DataReader associated with this Command which must be closed first. I've spent too much time figuring out where the problem is so I would appreciate any help / solutions. Thanks a lot
13 Replies
jami1217
jami1217OP8mo ago
Here's the code:
jami1217
jami1217OP8mo ago
basically for each found TotalAmount I would like to insert it into another table in my DB.
Angius
Angius8mo ago
Something that should've been disposed, wasn't. Or something that should've been awaited, wasn't. Or something that should've been async Task was async void and not handled properly
Jimmacle
Jimmacle8mo ago
yeah it seems pretty clear, you aren't cleaning up a datareader before trying to reuse a database command
Angius
Angius8mo ago
Jimmacle
Jimmacle8mo ago
is there even a point in reusing a command :pepethink:
Angius
Angius8mo ago
We will never learn, the OP vanished
jami1217
jami1217OP8mo ago
I WORKED IT OUT NEVER MIND Thanks a lot for your help
Angius
Angius8mo ago
What was the issue, out of curiosity?
jami1217
jami1217OP8mo ago
I actually declared: List<(string, string, decimal)> paymentDataList = new List<(string, string, decimal)>(); and put: paymentDataList.Add((paymentTypeID, description, totalAmount)); into loop 'while' then retrieved the data to make a db entry foreach (var data in paymentDataList) { InsertIntoDailyReportItem(reportID, data.Item1, data.Item3); }
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiX8mo ago
Use the /close command to mark a forum thread as answered Use the /close command to mark a forum thread as answered
Want results from more Discord servers?
Add your server