Link to home
Start Free TrialLog in
Avatar of andrewmilner
andrewmilner

asked on

Setting CommandTimeout on ObjectDataSource c#

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?
//Class1.cs
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();
            adapter.SetCommandTimeout(0);
        }
    }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of wht1986
wht1986
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of andrewmilner
andrewmilner

ASKER

IT WORKS!!!!!!
YES!.
THANK YOU!