I'm facing a random error on .Net templating.
There is already an open DataReader associated with this Command which must be closed first.
The above error is occurring when multiple pages are publishing using the .Net template CT.
When I google about this error, I saw many question on Stackoverflow. Most of the answers are mentioned that
- Set
MultipleActiveResultSets=True
on the connection string
Example:
Server=server;Initial Catalog=database;MultipleActiveResultSets=true;....
- Connection is not disposed
I don't think that we have facility on configuration to set MultipleActiveResultSets=True
Please suggest.
UPDATE:
While code accessing below lines, error encounters.
ItemFields itemFields = new ItemFields(RootElement, Schema);
Component.Content
This will happen only when multiple pages are published at a time and also, there are multiple places like accessing keywords description
the same error occurs.
StackTrace:
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.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
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.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
at Tridion.ContentManager.Data.AdoNet.Sql.SqlDatabaseUtilities.Execute(StoredProcedureInvocation storedProcedureInvocation)
at Tridion.ContentManager.Data.AdoNet.IdentifiableObjectDataMapper.Read(TcmUri id, StoredProcedureInvocation spInvocation)
at Tridion.ContentManager.Data.AdoNet.IdentifiableObjectDataMapper.Tridion.ContentManager.Data.IIdentifiableObjectDataMapper.Read(TcmUri id)
at Tridion.ContentManager.Session.GetDataObject(TcmUri id)
at Tridion.ContentManager.IdentifiableObject.Load(LoadFlags flags, Boolean forceReload)
at Tridion.ContentManager.ContentManagement.VersionedItem.Load(LoadFlags flags, Boolean forceReload)
at Tridion.ContentManager.IdentifiableObject.get_CurrentState()
at Tridion.ContentManager.ContentManagement.Component.get_Content()
***
***
***
Hope this will help in understanding the problem.