[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1184
  • Last Modified:

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

0
andrewmilner
Asked:
andrewmilner
1 Solution
 
wht1986Commented:
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

0
 
andrewmilnerAuthor Commented:
IT WORKS!!!!!!
YES!.
THANK YOU!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now