Thursday, April 14, 2011

SQLDatasource CommandTimeout not working

Good day,

I'm using a SQLDataSource with a dynamic query generated c#, based on user choices in many fields. However, since our tables are very large, sometimes, I get a command timeout exception.

I tried to set the property in 'Selecting' of the SqlDataSource like so:

protected void SqlDataSource_PSearch_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
    e.Command.CommandTimeout = 900;            
}

but with not luck, like if this attribute was ignored.

.NET 2.0, Sql server 2005.

Any idea?

From stackoverflow
  • I'm not very familiar with SqlDataSource, but the documentation for CommandTimeout mentions two possibilities:

    • The CommandTimeout property will be ignored during asynchronous method calls such as BeginExecuteReader.

    • CommandTimeout has no effect when the command is executed against a context connection (a SqlConnection opened with "context connection=true" in the connection string).

    Are you using AJAX? That may cause an asynchronous method call.

    Cedric Aube : No, I'm not using ajax, nor context "connection=true" in the connection string

0 comments:

Post a Comment