3

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.

  • Are you using any code to directly interacting with any DBMS, whether Tridion CM/Broker or any other Custom DB? – Pankaj Gaur May 20 '13 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. – Siva Charan May 20 '13 at 13:18
  • is it possible to share your code? – Pankaj Gaur May 20 '13 at 13:26
  • @PankajGaur: I have updated the question with few more information. – Siva Charan May 20 '13 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 May 20 '13 at 15:53
2

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

https://stackoverflow.com/questions/6062192/there-is-already-an-open-datareader-associated-with-this-command-which-must-be-c

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

thanks

| improve this answer | |
  • Thanks john but I already said in the question that to set the connection string with MultipleActiveResultSets=True. – Siva Charan May 20 '13 at 14:31
  • But unfortunately, I am not accessing the database directly to set MARS as True. – Siva Charan May 20 '13 at 14:32
  • I suspect that the tridion DLL's has a bug, sorry if am wrong. – Siva Charan May 20 '13 at 14:34
  • @SivaCharan - didn't see that :S – johnwinter May 20 '13 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. – Siva Charan May 20 '13 at 15:02
1

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.

| improve this answer | |
  • Only if your templates are doing something "weird". I never had trouble with multiple tender threads – Nuno Linhares May 21 '13 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 – Siva Charan May 21 '13 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 May 21 '13 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). – Bart Koopman Jul 18 '16 at 8:40
-2

This was able to help to resolve this problem:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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