Home All Groups Group Topic Archive Search About

TableAdapter and CommandTimeout

Author
24 Jan 2006 10:31 AM
Jurica Smircic
Is there any way to change CommandTimeout on commands that are generated
using TableAdapter wizard?

Author
24 Jan 2006 7:58 PM
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.


Show quote
"Jurica Smircic" <Jurica Smir***@discussions.microsoft.com> wrote in message
news:F74EB302-7EAD-4E9D-B148-1F20A21FBD8C@microsoft.com...
> Is there any way to change CommandTimeout on commands that are generated
> using TableAdapter wizard?
Author
24 Jan 2006 10:55 PM
Jurica Smircic
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.

Show quote
"AMDRIT" wrote:

> 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.
>
>
> "Jurica Smircic" <Jurica Smir***@discussions.microsoft.com> wrote in message
> news:F74EB302-7EAD-4E9D-B148-1F20A21FBD8C@microsoft.com...
> > Is there any way to change CommandTimeout on commands that are generated
> > using TableAdapter wizard?
>
>
>
Author
7 Feb 2006 3:55 PM
PIEBALD
> 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?
Author
8 Feb 2006 6:37 PM
PIEBALD
"Jurica Smircic" wrote:

> 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 ;
                    }
                }
            }
        }
    }
}

AddThis Social Bookmark Button