How to set sql timeout on the sqldatasource control

G

Guest

Hi
I have a query which takes longer than the default (30seconds I guess) time
to process (I am using the full text index in a sql server stored
procedure!). The results are place on a web page using the gridview and the
sql datasource controls.

In .Net 1.1 I guess I would have used the command.timeout property (I
already know that the web.config httpRuntime executionTimeout setting and the
sql connection timeout don't affect this the timeout I'm getting)

I am wondering how I access the sql timeout property with these new .net 2.0
controls which are great by the way.

I am guessing that I somehow reach into a the equivalent of the sqlcommand
in the datasource_selecting event and set the property. Anyone done this or
have any ideas?
 
W

Walter Wang [MSFT]

Hi,

Thank you for your post.

You can set the select command's timeout value in SqlDataSource's Selecting
event:

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

Hope this helps.

Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Joined
Aug 18, 2006
Messages
1
Reaction score
0
HI, I'm connecting to the database from an asp page, could you show me the full code to establish the connection using SqlDataSource and setting the commandtimeout option, i'm having the same problem with a long running stored procedure...
 
Joined
Jul 22, 2009
Messages
1
Reaction score
0
Excellent, it worked, many thanks!


Walter Wang [MSFT] said:
Hi,

Thank you for your post.

You can set the select command's timeout value in SqlDataSource's Selecting
event:

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

Hope this helps.

Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Joined
Dec 18, 2009
Messages
1
Reaction score
0
Walter Wang [MSFT] said:
Hi,

Thank you for your post.

You can set the select command's timeout value in SqlDataSource's Selecting
event:

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

Hope this helps.

Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Excellent, Walter! Thanks for this very helpful tip that I've been looking for too!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top