TableAdapter and CommandTimeout


G

Guest

Is there any way to change CommandTimeout on commands that are generated
using TableAdapter wizard?
 
Ad

Advertisements

A

AMDRIT

the timeout is not set by the wizard and takes the default timeout (30
seconds). In the InitializeComponents code section is where all of your
generated code will live. You can specify it there.
 
G

Guest

There is no InitializeComponents method in wizard generated code. And even ih
there were one, modifing wizard generated code is not a solution for me
becaouse every time i change something in DataSet design the code is
regenerated.
Maybe i should point out that i mean about new TableAdapter wizard
funcionality in VS 2005, not DataAdapter wizard that is used to generate
untyped DataAdapters.
 
G

Guest

Is there any way to change CommandTimeout on commands that are generated
using TableAdapter wizard?
A colleague and I hit the same problem yesterday. The only work-around is to
alter the generated code in xxxDataSet.Designer.cs which is no solution.

The xxxTableAdapter should expose the Command objects (they're private) or
at least their CommandTimeout properties. They should in fact be exposed in
the designer.

I just took a quick look to see if I could find the template that's used, in
hopes of altering it, but didn't find it. Anyone know where it can be found?
 
Ad

Advertisements

G

Guest

Jurica Smircic said:
Is there any way to change CommandTimeout on commands that are generated
using TableAdapter wizard?
Ah, the power of partial classes! Create and include a file that contains
something like below (make it match the generated code) then in, for instance
Form1.cs, do:

private void Form1_Load ( object sender , EventArgs e )
{
this.xxxTableAdapter.SelectCommandTimeout = 0 ;
this.xxxTableAdapter.Fill ( this.xxxDataSet.xxx );
}

-----------------------

namespace xxx.xxxDataSetTableAdapters
{
public partial class xxxTableAdapter
{
public int InsertCommandTimeout
{
get
{
return ( this._adapter.InsertCommand.CommandTimeout ) ;
}

set
{
this._adapter.InsertCommand.CommandTimeout = value ;
}
}

public int UpdateCommandTimeout
{
get
{
return ( this._adapter.UpdateCommand.CommandTimeout ) ;
}

set
{
this._adapter.UpdateCommand.CommandTimeout = value ;
}
}

public int DeleteCommandTimeout
{
get
{
return ( this._adapter.DeleteCommand.CommandTimeout ) ;
}

set
{
this._adapter.DeleteCommand.CommandTimeout = value ;
}
}

public int SelectCommandTimeout
{
get
{
return ( this._commandCollection[0].CommandTimeout ) ;
}

set
{
for ( int i = 0 ; i < this._commandCollection.Length ; i++ )
{
if ( ( this._commandCollection [ i ] != null ) )
{
( (System.Data.SqlClient.SqlCommand) (
this._commandCollection [ i ] ) ).CommandTimeout = value ;
}
}
}
}
}
}
 

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

Similar Threads

CommandTimeout 4
CommandTimeout 1
CommandTimeout 1
CommandTimeOut Problem 2
CommandTimeout Property 1
CommandTimeout confusion 0
SQLCommand, CommandTimeout property 0
TableAdapter 0

Top