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


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.


While code accessing below lines, error encounters.

ItemFields itemFields = new ItemFields(RootElement, Schema);


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.


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.

  • Are you using any code to directly interacting with any DBMS, whether Tridion CM/Broker or any other Custom DB? Commented May 20, 2013 at 13:05
  • @PankajGaur: No direct interaction with database. My code is only for reading components and keywords. Its simple code which refers on different CT's. Commented May 20, 2013 at 13:18
  • is it possible to share your code? Commented May 20, 2013 at 13:26
  • @PankajGaur: I have updated the question with few more information. Commented May 20, 2013 at 14:30
  • All I can think of is indeed a defect in Tridion - but this is a pretty big one, pretty sure it was fixed by now. Check your hotfixes/contact support.
    – Nuno Linhares
    Commented May 20, 2013 at 15:53

3 Answers 3


There's quote a bit of information online when googling this error message, for example:


Perhaps sharing your code here will get the answer you are looking for.


  • Thanks john but I already said in the question that to set the connection string with MultipleActiveResultSets=True. Commented May 20, 2013 at 14:31
  • But unfortunately, I am not accessing the database directly to set MARS as True. Commented May 20, 2013 at 14:32
  • I suspect that the tridion DLL's has a bug, sorry if am wrong. Commented May 20, 2013 at 14:34
  • @SivaCharan - didn't see that :S
    – johnwinter
    Commented May 20, 2013 at 15:00
  • Since I was calling the base functions of tridion nothing else am doing. I don't have any DB related code. DB connection are involved only on tridion DLL's where call will go to DB and get the contents of it. Commented May 20, 2013 at 15:02

After a lot of effort on debugging and understanding the issue, I came to know that

Issue looks like causing due to MULTI-THREADING.

How I conclude:

If I set Number of Rendering as

  1. 1 on MMC Snap-In, there is no error
  2. More than 1 on MMC Snap-In, then random errors will encounter.

How to Fix:

Contact Tridion Support to fix the issue.

  • Only if your templates are doing something "weird". I never had trouble with multiple tender threads
    – Nuno Linhares
    Commented May 21, 2013 at 2:17
  • @NunoLinhares: Sorry Nuno, there is nothing weird code written. When the call tries to access Itemfields or Component.Content... above mentioned error encounters randomly Commented May 21, 2013 at 10:17
  • OK. Reason why I say this is that I never had problems with using multi-threaded publishers (except in a customer that insisted that writing from templates was an acceptable practice)
    – Nuno Linhares
    Commented May 21, 2013 at 14:45
  • Not shure how to read this as an answer, you mention: "it looks like a multi threading issue", so you are not sure, which means this is not an answer? You end with: "how to fix; contact customer support", so you haven't found an answer? If both of these conslusions are true, I suggest you delete this answer and edit your question and add this information in your question. An answer should contain a solution, and not a suggestion to contact customer support (unless the suggestion is to contact CS for a certain hotfix, in which case you can mention what fix that is, so others can do the same). Commented Jul 18, 2016 at 8:40

This was able to help to resolve this problem:

     <add name="myconnConnectionString" connectionString="Data Source=;Initial Catalog=dbname;MultipleActiveResultSets=true;User ID=sguser;Password=mypass" providerName="System.Data.SqlClient"/>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.