Setting CommandTimeout on ObjectDataSource c#

Posted on 2009-04-19
Last Modified: 2013-11-26
I've had a previous question running but I posted in wrong zone so here is the continuation.

I have been trying to wire up a CommandTimeout to an ObjectDatasource without success.

I have a DataSet.xsd with a table adaptor and I have created a partial class with the same namespace and am calling the code within that from the ObjectCreated method of the ObjectDataSource.

It isn't however working.

What am I doing wrong here?

namespace DataSet1TableAdapters


    public partial class ReplenReportsTableAdapter


        public void SetCommandTimeout(int timeout)


            for (int i = 0; i < this.CommandCollection.Length; i++)

                if (this.CommandCollection[i] != null)

                    this.CommandCollection[i].CommandTimeout = timeout;





//Pres ASPX CS page


protected void ObjectDataSource1_ObjectCreated(object sender, ObjectDataSourceEventArgs e)


        if (e.ObjectInstance != null)


            Response.Write("not null");

            DataSet1TableAdapters.ReplenReportsTableAdapter adapter = new DataSet1TableAdapters.ReplenReportsTableAdapter();




Open in new window

Question by:andrewmilner
    LVL 12

    Accepted Solution

    Dont create a new instance of the table adapter. the arguement of the method contains the instance it will be using.
     protected void ObjectDataSource1_ObjectCreated(object sender, ObjectDataSourceEventArgs e)
            DataSet1TableAdapters.TestTableTableAdapter adpt = (DataSet1TableAdapters.TestTableTableAdapter)e.ObjectInstance;
            adpt.CommandTimeout = 0;

    Open in new window


    Author Comment

    IT WORKS!!!!!!

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    This video discusses moving either the default database or any database to a new volume.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now