C
C#10mo 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
jami1217OP10mo ago
Here's the code:
jami1217
jami1217OP10mo ago
basically for each found TotalAmount I would like to insert it into another table in my DB.
Angius
Angius10mo 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
Jimmacle10mo ago
yeah it seems pretty clear, you aren't cleaning up a datareader before trying to reuse a database command
Angius
Angius10mo ago
Jimmacle
Jimmacle10mo ago
is there even a point in reusing a command :pepethink:
Angius
Angius10mo ago
We will never learn, the OP vanished
jami1217
jami1217OP10mo ago
I WORKED IT OUT NEVER MIND Thanks a lot for your help
Angius
Angius10mo ago
What was the issue, out of curiosity?
jami1217
jami1217OP10mo 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 User10mo ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiX10mo ago
Use the /close command to mark a forum thread as answered Use the /close command to mark a forum thread as answered

Did you find this page helpful?