✅ 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
basically for each found TotalAmount I would like to insert it into another table in my DB.
Something that should've been disposed, wasn't. Or something that should've been
await
ed, wasn't. Or something that should've been async Task
was async void
and not handled properlyyeah it seems pretty clear, you aren't cleaning up a datareader before trying to reuse a database command
SO also mentions this: https://stackoverflow.com/a/6064422/6042255
is there even a point in reusing a command :pepethink:
We will never learn, the OP vanished
I WORKED IT OUT
NEVER MIND
Thanks a lot for your help
What was the issue, out of curiosity?
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•8mo ago
Message Not Public
Sign In & Join Server To View
Use the /close command to mark a forum thread as answered
Use the /close command to mark a forum thread as answered