SqlDataSource Command Timeout

I was dealing with an ASP.NET SqlDataSource query that kept timing out, which was annoying because I was trying to run my application through the Database Tuning Advisor (a SQL Server 2005 tool that analyzes trace logs and recommends indexes). The timeouts were preventing me from getting through my whole test case, though.

So, I found a quick solution to setting the timeout value for a SqlDataSource: add a Selecting event handler and put

protected void mySqlDataSource_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
e.Command.Command = 300; // 5 min timeout
}

Easy peasy. 🙂

0