I have many users on my web site (20000-60000 per day), which is a download site for mobile files. I have remote access to my server (windows server 2008-R2).
I\'ve
Timeout expired because the sql query is taking more time than you set in sqlCommand.CommandTimeout property.
Obviously you can increase CommandTimeout to solve this issue but before doing that you must optimize your query by adding index. If you run your query in Sql server management studio including actual execution plan then Sql server management studio will suggest you proper index. Most of the case you will get rid of timeout issue if you can optimize your query.
You have to set CommandTimeout attribute. You can set the CommandTimeout attribute in DbContext child class.
public partial class StudentDatabaseEntities : DbContext
{
public StudentDatabaseEntities()
: base("name=StudentDatabaseEntities")
{
this.Database.CommandTimeout = 180;
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public virtual DbSet<StudentDbTable> StudentDbTables { get; set; }
}
@SilverLight.. This is clearly an issue with a Database object. It can be a badly written query, or missing indexes. But as of now I won't suggest you to increase the timeout without investigating the issue with your Database objects
NovinMedia.Data.DbObject.RunProcedure(String storedProcName, IDataParameter[] parameters, Int32& rowsAffected) +209
Put a breakpoint on this line of code to findout the procedure name and then optimise the procedure by looking at its execution plan.
I cannot help you more till the time you post details about the stored procedure.
I had the same issue and resolved by adding "Connection Time" value in web.config file. locate the connectionStrings and add Connection Timeout=3600"
here is the sample
<connectionStrings>
<add name="MyConn" providerName="System.Data.SqlClient" connectionString="Data Source=MySQLServer;Initial Catalog=MyDB;User ID=sa;Password=123;Connection Timeout=3600" />
</connectionStrings>
Also you need to check if individual record is not getting updated in the logic because with update trigger in the place causes time out error too.
So, the solution is to make sure you perform bulk update after the loop/cursor instead of one record at a time in the loop.
Also make sure you just don't have a pending transaction. :)
I was doing some tests around and began a transaction to be safe but never closed it. I wish the error would have been more explicit but oh well!