Tuesday, October 30, 2012

CommandTimeout in Entity Framework

I use Entity Framework in my web application and then use it to execute a stored procedure command in SQL Server. Unluckily, I receive a connection timeout issue. First, I try to add 'Connection Timeout=120;' into connection string. But, the problem still exists. Then, solving the issue by CommandTimeout 

using (RSEntities rEntity = new RSEntities())
{
  //import data from temp tables
  rEntity.CommandTimeout = 120;
  rEntity.ExecuteStoreCommand("EXEC dbo.ImportMdbData");
}

No comments:

Post a Comment