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

P

Piotrek

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
 
B

Brock Allen

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

Piotrek

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
 
B

Brock Allen

I thought those were the same?

In any event, you can access the command timeout via: DataAdapter.SelectCommand.CommandTimeout.
 
Joined
May 31, 2006
Messages
2
Reaction score
0
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;
}
}
}
 
Joined
May 31, 2006
Messages
2
Reaction score
0
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;
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top