C# .NET - System.Data.EntityCommandExecutionException

Asked By Bhawana on 13-Jun-12 04:05 AM
i am getting below mention error when i am trying to delete records from gridview.

An error occurred while executing the command definition. See the inner exception for details. at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)

i am using this code 

if ((Request.Form["__EVENT"] + "").Equals("delete"))
SystemEntities meta = new SystemEntities(Common.SystemEntities());
int _idD = int.Parse(Request.Form["__EVENT"]);
CDR_Collection objIPCol = meta.CDR_Collection.Single(ipCol => ipCol.ConfigID == _idD);
meta.DeleteObject(meta.CDR_Collection.Single(ipCol => ipCol.ConfigID == _idD));


lblMsg.Visible = true;
lblMsg.Text = GetLocalResourceObject("msgDel").ToString();
catch (Exception ex)
lblMsg.Visible = true;
lblMsg.Text = GetLocalResourceObject("msgUnableDel").ToString() + ex.Message;// +"<br><br>" + ex.StackTrace;

TSN ... replied to Bhawana on 13-Jun-12 04:18 AM


Hi this may be caused due to multiple reason , lets for the first try to increase the time out in the Connection string in the web.config

Connection Timeout=60

Also check the  objectContext.CommandTimeout.

Second  Reason may be due to the change of columns names or mismatch in the mappings, if this is the case try to recreate the schema

Bhawana replied to TSN ... on 13-Jun-12 05:06 AM
same error,

kalpana aparnathi replied to Bhawana on 13-Jun-12 06:54 AM

You can try setting the http://msdn.microsoft.com/en-us/library/system.data.objects.objectcontext.commandtimeout.aspx property.Gets or sets the timeout value, in seconds, for all object context operations. A null value indicates that the default value of the underlying provider will be used.


Bhawana replied to kalpana aparnathi on 15-Jun-12 06:19 AM

its working now