OK I have found time to test & verify this.
This is working OK for me in the latest version of Umbraco.
Is there anything unusual about your Database or connection string that I may need to be aware about?
Full SQL Server, SQL Azure, SQL CE DB or...?
As an alternative for now you could use the following:
@{
using (var formStorage = new FormStorage())
{
using (var recordStorage = new RecordStorage())
{
var form = formStorage.GetForm(Guid.Parse("ede58fd2-9eff-4f88-a5d6-053042983681"));
var records = recordStorage.GetAllRecords(form).Where(x => x.UmbracoPageId == Model.Content.Id && x.State == FormState.Approved).ToList();
}
}
}
Rather than doing this directly in a view. It would be better of course to do this logic in a controller and pass records to your view, but of course there are many ways to do the same thing with Umbraco.
I know this issue is old, but it's still not fixed.
The workaround you posted is useless when you use the same form on multiple pages and want to show only comments made on that page.
Right now we have a comments form spanning multiple news pages.
GetAllRecords() retrieves all 2500 comments, which takes around a minute, then we can do the filtering. It's just not feasible.
And the issue with the open data reader using the old Library classes are still present, which leads me to believe that 0 hours have gone into fixing this issue, while being over 2 years old. /rant
Whenever i get the "There is already an open DataReader associated with this Command which must be closed first." error (happens sometimes) it's always solved for me by adding MultipleActiveResultSets=true in the connectionstring.
Working with Record data = There is already an open DataReader associated
Hi
I'm trying to get Umbraco Forms records data in Umbraco 7.4.3
I'm following the documentation here: https://our.umbraco.org/documentation/Addons/UmbracoForms/Developer/Working-With-Data/
My purpose is to get all records from a form listed - related to the current page
It is resulting in this error There is already an open DataReader associated with this Command which must be closed first.
I have tried isolating, but nothing seems to work. So I'm wondering whats the correct way of getting data from Umbraco Forms.
Cheers
Hi Søren,
With the Razor code below you should get all the approved comments from your form.
Hope this helps, if not could you please try to paste the current code that you have right now.
Best,
/Dennis
Hi Dennis,
I'm using exactly your code in an empty view to avoid any other code to interrupt.
I have upgraded Umbraco forms to 4.3.2
Running Umbraco 7.4.3
I get this error message There is already an open DataReader associated with this Command which must be closed first.
when I try to get the records
Hello Soren,
Can you send over the example you are using please?
As your one liner does not match up from Dennis's example he sent you.
You could try adding
.ToList()
to the end of your line to see if this helps resolve your problem.Thanks,
Warren
Hi Warren,
The one liner is the same - It should also work this way. I have tried Dennis's with the same result.
My code is isolated this - which returns in the error
I'm am using the only documentation there is https://our.umbraco.org/documentation/Products/UmbracoForms/Developer/Working-With-Data/
I think I will write my own sql - this is too weird.
Morning Soren,
Sorry this is not working. I will test & verify this morning and get back to you shortly.
Can you please confirm what version of Umbraco Forms you are using?
Thanks,
Warren
OK I have found time to test & verify this.
This is working OK for me in the latest version of Umbraco.
Is there anything unusual about your Database or connection string that I may need to be aware about?
Full SQL Server, SQL Azure, SQL CE DB or...?
As an alternative for now you could use the following:
Rather than doing this directly in a view. It would be better of course to do this logic in a controller and pass
records
to your view, but of course there are many ways to do the same thing with Umbraco.Thanks,
Warren :)
Hi Warren,
It was exactly what I was trying to figure out how to do. Your method with FormStorage // Recordstorage did the trick.
This way is also more easy to filter a list.
Regarding the error - I'm on a SQL 2008 - don't know if there are any issues here
Hi Warren
I know this issue is old, but it's still not fixed. The workaround you posted is useless when you use the same form on multiple pages and want to show only comments made on that page. Right now we have a comments form spanning multiple news pages. GetAllRecords() retrieves all 2500 comments, which takes around a minute, then we can do the filtering. It's just not feasible. And the issue with the open data reader using the old Library classes are still present, which leads me to believe that 0 hours have gone into fixing this issue, while being over 2 years old. /rant
Whenever i get the "There is already an open DataReader associated with this Command which must be closed first." error (happens sometimes) it's always solved for me by adding MultipleActiveResultSets=true in the connectionstring.
Could be worth a shot!
Similar issue from StackOverflow: http://stackoverflow.com/questions/6062192/there-is-already-an-open-datareader-associated-with-this-command-which-must-be-c
Dennis,
You, sir, are a legend. Fixed the same problem for me.
h5yr
Cheers,
Al
Thank you Al! :)
Glad it worked out for you!!
Have a good weekend!
is working on a reply...