Umbraco Forms - There is already an open DataReader associated with this Command which must be closed first

Friday, December 7, 2018 / mcchu28


An exception of type 'System.InvalidOperationException' occurred in Umbraco.Core.dll but was not handled in user code

Additional information: There is already an open DataReader associated with this Command which must be closed first.

Solution: Add to your connection string in web.config to have MultipleActiveResultSets=True


Stack trace:
at System.Data.SqlClient.SqlInternalConnectionTds.ValidateConnectionForExecute(SqlCommand command)
at System.Data.SqlClient.SqlConnection.ValidateConnectionForExecute(String method, SqlCommand command)
at System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
at StackExchange.Profiling.Data.ProfiledDbCommand.ExecuteDbDataReader(CommandBehavior behavior) in file:///c:/Code/github/SamSaffron/MiniProfiler/StackExchange.Profiling/Data/ProfiledDbCommand.cs:line 235
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
at Umbraco.Core.Persistence.PetaPocoCommandExtensions.<>c__DisplayClass5_0.b__0()
at Umbraco.Core.Persistence.FaultHandling.RetryPolicy.ExecuteAction[TResult](Func`1 func)
at Umbraco.Core.Persistence.PetaPocoCommandExtensions.ExecuteReaderWithRetry(IDbCommand command, RetryPolicy cmdRetryPolicy, RetryPolicy conRetryPolicy)
at Umbraco.Core.Persistence.PetaPocoCommandExtensions.ExecuteReaderWithRetry(IDbCommand command, RetryPolicy retryPolicy)
at Umbraco.Core.Persistence.PetaPocoCommandExtensions.ExecuteReaderWithRetry(IDbCommand command)
at Umbraco.Core.Persistence.Database.d__74`1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Umbraco.Forms.Data.Storage.RecordFieldStorage.GetAllRecordFields(Record record, Form form)
at Umbraco.Forms.Mvc.DynamicObjects.Library.QueryRecords(Guid formId, Int32 pageId, Boolean submitted)
at Umbraco.Forms.Mvc.DynamicObjects.Library.GetApprovedRecordsFromForm(String formId)