Jump to content


Photo

Error A First Chance Exception Of Type System.data.entitycommandexecutionexception Occurred In System.data.entity.dll


  • Please log in to reply
1 reply to this topic

#1 dharric

dharric

    New Member

  • Members
  • Pip
  • 4 posts

Posted 23 August 2010 - 09:53 AM

I have seen this error for other user's, even in this forum. But not in my particular context. I have built a silverlight reporting application which is using wcf and entity framework for data retrieval. Everything seems to work fine initially but after having run through several reports I get the error above on calls that initial were working. In other words there seems to be some sort of resource issue in my code somewhere. Unfortunately that line is the only error I'm getting back. But I do suspect that the exception itself is coming from somewhere in the following code:

CODE
public T GetPatchInventoryByQueryString<T,I>(string queryStr)
            where T : IList<I>
            where I : IPatchInventory
        {
            EntityConnection econn = new EntityConnection("name=LDMS861Entities1");
            try
            {
                IList<PatchInventory> patches = _container.Resolve<IList<PatchInventory>>();

                if (econn.State == ConnectionState.Closed)
                    econn.Open();
                using (econn)
                {
                    using (EntityCommand scmd = new EntityCommand(queryStr, econn))
                    {
                        using (EntityDataReader edr = scmd.ExecuteReader(CommandBehavior.SequentialAccess))
                        {
                            while (edr.Read())
                            {
                                patches.Add(GetPatchInventoryByDataRecord<PatchInventory>(edr));
                            }
                        }
                        return (T)patches;
                    }
                }
            }
            finally
            {
                if (econn.State == ConnectionState.Open)
                {
                    econn.Close();
                    econn.Dispose();
                }
            }
        }


Any ideas?

#2 JulieLerman

JulieLerman

    Advanced Member

  • O'Reilly Author
  • PipPipPipPipPipPipPipPip
  • 334 posts

Posted 05 October 2010 - 05:41 AM

not too many ideas here. Seems that there is some collision here but without the details bedhind that error message, I can't tell.

julie




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users