• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1229
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

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