How to set commandTimeout for getData method of TableAdapter (ASP.NET 2.0)?

Discussion in 'ASP .Net' started by Piotrek, Apr 11, 2006.

  1. Piotrek

    Piotrek Guest

    Hi all.

    I am developing some web application in which I use datasets, which
    were generated using dataSetDesigner. My dataset has a TableAdapter,
    which has GetData method. Users of my application sometimes get timeout
    while executing this GetData method.

    I would like to increase CommandTimeout for this GetData method, but I
    cannot find this property. How can I do that?

    Thanks in advance,
    Piotrek
    Piotrek, Apr 11, 2006
    #1
    1. Advertising

  2. Piotrek

    Brock Allen Guest

    You could alter the connection string used to initialize the DataAdapter
    to include the timeout desired.

    -Brock
    http://staff.develop.com/ballen


    > Hi all.
    >
    > I am developing some web application in which I use datasets, which
    > were generated using dataSetDesigner. My dataset has a TableAdapter,
    > which has GetData method. Users of my application sometimes get
    > timeout while executing this GetData method.
    >
    > I would like to increase CommandTimeout for this GetData method, but I
    > cannot find this property. How can I do that?
    >
    > Thanks in advance,
    > Piotrek
    Brock Allen, Apr 11, 2006
    #2
    1. Advertising

  3. Piotrek

    Piotrek Guest

    Hi Brock

    I am not sure if it is possible to set CommandTimeout in the connection
    string. In my opinion only connectionTimeout can be set there.

    Piotrek
    Piotrek, Apr 12, 2006
    #3
  4. Piotrek

    Brock Allen Guest

    I thought those were the same?

    In any event, you can access the command timeout via: DataAdapter.SelectCommand.CommandTimeout.

    -Brock
    http://staff.develop.com/ballen


    > Hi Brock
    >
    > I am not sure if it is possible to set CommandTimeout in the
    > connection string. In my opinion only connectionTimeout can be set
    > there.
    >
    > Piotrek
    >
    Brock Allen, Apr 12, 2006
    #4
  5. Piotrek

    Piotrek Guest

    I am afraid not.
    Try it with TableAdapter and some Fill or GetData method.

    Piotrek
    Piotrek, Apr 13, 2006
    #5
  6. Piotrek

    SalimMorgan

    Joined:
    May 31, 2006
    Messages:
    2
    TableAdapter Timeout

    The only way to change this from the default of 30 seconds is to use partial classes to extend the table adapter class.

    The latter is generated code which you can find by using "Go to Definition" within VS. Note that it is already a partial class. Create your own file and use the same namespace and partial class name. Next, add a property for CommandTimeout as follows:

    public partial class xxxxxxTblTableAdapter
    {
    public int SelectCommandTimeout
    {
    get
    {
    return this.CommandCollection[0] .CommandTimeout;
    }
    set
    {
    this.CommandCollection[0].CommandTimeout = value;
    }
    }
    }
    SalimMorgan, May 31, 2006
    #6
  7. Piotrek

    SalimMorgan

    Joined:
    May 31, 2006
    Messages:
    2
    TableAdapter CommandTimeout (continued)

    Don't forget to get the namespace from the TA file, which I didn't put in the code snippet. After you create this partial class file, you can set the CommandTimeout after instantiating your TableAdapter and before calling GetData() like this:

    tbladptr.SelectCommandTimeout = 300;
    SalimMorgan, May 31, 2006
    #7
  8. Piotrek

    robwafle

    Joined:
    Aug 14, 2006
    Messages:
    1
    Thanks!

    Thanks! I was trying to figure that out!
    robwafle, Aug 15, 2006
    #8
    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. Piotrek
    Replies:
    15
    Views:
    37,928
    amchi
    Aug 20, 2008
  2. Piotrek
    Replies:
    4
    Views:
    33,473
    shaileshk
    Apr 15, 2008
  3. UnglueD

    XML Schema CommandTimeout

    UnglueD, Aug 31, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    436
    UnglueD
    Aug 31, 2006
  4. Tim Meagher
    Replies:
    1
    Views:
    306
    Bob Barrows [MVP]
    Oct 4, 2005
  5. dwhalen
    Replies:
    4
    Views:
    270
    Xavier
    Feb 22, 2007
Loading...

Share This Page