Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Eli Estes 9 posts 119 karma points
    Aug 10, 2016 @ 15:39
    Eli Estes
    0

    Getting error message: There is already an open DataReader associated with this Command which must be closed first.

    We sometimes see a message in the Umbraco log:

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

    We think it might be related to an issue we've been having where Umbraco will create an entirely new set of blank member properties in the database. These new properties are being used by Umbraco instead of the actual member properties and the member is not allowed to login because the "Approved" flag is not set.

    We're currently using Umbraco 7.4.3, but we've seen this error and the duplicate member properties issue on Umbraco 6.2.1. We're using SQL Express 2012 as our database.

    I've read that the message indicates that this is due to having multiple active result sets open and some have suggested enabling multiple active result sets in the connection string. From what I've read it's best practice to not enable MARS unless you have a business need to do so, so I figured I would check around to see if anyone else using it or if MARS is something we should have enabled for Umbraco?

    Here is the entire error log entry:

    2016-08-08 13:39:19,454 [P1136/D2/T79] ERROR Umbraco.Core.Persistence.UmbracoDatabase - Database exception occurred
    System.InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first.
       at System.Data.SqlClient.SqlInternalConnectionTds.ValidateConnectionForExecute(SqlCommand command)
       at System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean async)
       at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite)
       at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
       at StackExchange.Profiling.Data.ProfiledDbCommand.ExecuteNonQuery() in c:\Code\github\SamSaffron\MiniProfiler\StackExchange.Profiling\Data\ProfiledDbCommand.cs:line 279
       at Umbraco.Core.Persistence.PetaPocoCommandExtensions.<>c__DisplayClass1.<ExecuteNonQueryWithRetry>b__0()
       at Umbraco.Core.Persistence.FaultHandling.RetryPolicy.ExecuteAction[TResult](Func`1 func)
       at Umbraco.Core.Persistence.Database.Update(String tableName, String primaryKeyName, Object poco, Object primaryKeyValue, IEnumerable`1 columns)
     2016-08-08 13:39:19,454 [P1136/D2/T79] ERROR Umbraco.Core.UmbracoApplicationBase - An unhandled exception occurred
    System.InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first.
       at System.Data.SqlClient.SqlInternalConnectionTds.ValidateConnectionForExecute(SqlCommand command)
       at System.Data.SqlClient.SqlInternalTransaction.Rollback()
       at System.Data.SqlClient.SqlTransaction.Rollback()
       at Umbraco.Core.Persistence.Database.CleanupTransaction()
       at Umbraco.Core.Persistence.Database.AbortTransaction()
       at Umbraco.Core.Persistence.Transaction.Dispose()
       at Umbraco.Core.Persistence.UnitOfWork.PetaPocoUnitOfWork.Commit(Action`1 transactionCompleting)
       at Umbraco.Core.Services.MemberService.Save(IMember entity, Boolean raiseEvents)
       at Umbraco.Web.Security.Providers.UmbracoMembershipProvider`2.GetUser(String username, Boolean userIsOnline)
       at Umbraco.Web.Security.MembershipHelper.GetCurrentMemberProfileModel()
       at XXXX.Controllers.HomeController.Home(String ReturnUrl) in C:\XXXXX\Controllers\HomeController.cs:line 67
       at lambda_method(Closure , ControllerBase , Object[] )
       at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
       at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<>c__DisplayClass2b.<BeginInvokeAction>b__1c()
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult)
       at System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState)
       at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
       at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
       at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
       at System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult)
       at System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState)
       at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
       at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
       at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
       at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
    
  • Streety 358 posts 568 karma points
    May 16, 2017 @ 10:03
    Streety
    0

    I had this issue.

    I was making an AJAX call which queried records via a poco. It seems the Query method was holding the data reader open whilst I was iterating over the results.

    So I dumped the query into a collection and iterated over that instead.

    Good old .ToList() saved my life. Not great for performance but it works.

Please Sign in or register to post replies

Write your reply to:

Draft