C
C#3mo 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
jami12173mo ago
Here's the code:
jami1217
jami12173mo ago
basically for each found TotalAmount I would like to insert it into another table in my DB.
Angius
Angius3mo 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
Jimmacle3mo ago
yeah it seems pretty clear, you aren't cleaning up a datareader before trying to reuse a database command
Angius
Angius3mo ago
Jimmacle
Jimmacle3mo ago
is there even a point in reusing a command :pepethink:
Angius
Angius3mo ago
We will never learn, the OP vanished
jami1217
jami12173mo ago
I WORKED IT OUT NEVER MIND Thanks a lot for your help
Angius
Angius3mo ago
What was the issue, out of curiosity?
jami1217
jami12173mo 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 User3mo ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiX3mo 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
More Posts
C# Integration with MulesoftWe are looking to re-do an application in microservice style and biz req is pushing Mulesoft for thaVisual Studio opening search results in the search dock, not main windowKinda unrelated to C#, but since a few updates ago Visual Studio started behaving weirdly for me. Logic on properly deploying thingsSo I've been getting into a more professional workflow (id say) with better github practices, workinSystem.AggregateException: 'Some services are not able to be constructedI stuck with this problem and don't understand how to fix it: InvalidOperationException: Unable to rMAUI. How to remove the Title Bar?I need to remove the top panel so that the user can not use the buttons on it.Help me sort out perhaps badly done folder/solution structure so I can add a shared Class LibraryOk, so I have two solutions which must be separate so I can execute them both at the same time so thUsing Roslyn in WebAssembly, error creating an AdHocWorkspaceHello, this could be a really convoluted use case and I don't know what sort of support is expected SignalR Blocking Issue: Infinite Wait When Calling a Method from ClientHello here is a Hub I implemented, the goal is to make a board game turn system, the most important How to connect to database? WPFHi, I was searching how to connect to database, but I couldn't find anything. I mean to connect non-✅ Help needed with WPF GUI# Hello, Good Day! ## Overview I just started with WPF a few weeks ago so I'm still quite new to a