How to set sql timeout on the sqldatasource control

Discussion in 'ASP .Net' started by =?Utf-8?B?RGFycmVuQg==?=, Jun 7, 2006.

  1. 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?
     
    =?Utf-8?B?RGFycmVuQg==?=, Jun 7, 2006
    #1
    1. Advertising

  2. 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.
     
    Walter Wang [MSFT], Jun 8, 2006
    #2
    1. Advertising

  3. =?Utf-8?B?RGFycmVuQg==?=

    marco.nannini

    Joined:
    Aug 18, 2006
    Messages:
    1
    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...
     
    marco.nannini, Aug 18, 2006
    #3
  4. =?Utf-8?B?RGFycmVuQg==?=

    cws2

    Joined:
    Jul 22, 2009
    Messages:
    1
    Excellent, it worked, many thanks!


     
    cws2, Jul 22, 2009
    #4
  5. =?Utf-8?B?RGFycmVuQg==?=

    Unsurreality

    Joined:
    Dec 18, 2009
    Messages:
    1
    Excellent, Walter! Thanks for this very helpful tip that I've been looking for too!
     
    Unsurreality, Dec 18, 2009
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sasa .

    SqlDataSource - command timeout?

    Sasa ., Sep 22, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    14,746
    WertmanTheMad
    Feb 15, 2005
  2. =?Utf-8?B?VmVhcg==?=
    Replies:
    1
    Views:
    5,049
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
    Mar 21, 2006
  3. Replies:
    1
    Views:
    1,074
  4. John Kotuby
    Replies:
    2
    Views:
    1,414
    John Kotuby
    Mar 27, 2007
  5. Mark Probert

    Timeout::timeout and Socket timeout

    Mark Probert, Oct 6, 2004, in forum: Ruby
    Replies:
    1
    Views:
    1,298
    Brian Candler
    Oct 6, 2004
Loading...

Share This Page