How can I change the table adapter's command timeout

后端 未结 15 1300
遇见更好的自我
遇见更好的自我 2020-12-10 02:12

I\'m using Visual Studio 2008 with C#.

I have a .xsd file and it has a table adapter. I want to change the table adapter\'s command timeout.

Thanks for your

15条回答
  •  囚心锁ツ
    2020-12-10 02:59

    Expanding on the already very useful answers for tableadapters that helped me a lot, I also had the need to read out the actual timeout value. Thus:

    namespace XTrans.XferTableAdapters
    {
    
        public partial class FooTableAdapter
        {
            int? _timeout = null;
    
            ///
            ///Get or set the current timeout in seconds for Select statements.
            ///
            public int CurrentCommandTimeout
            {
                get
                {
                    int timeout = 0;
    
                    if (_timeout != null)
                    {
                        timeout = (int)_timeout;
                    }
                    else
                    {
                        for (int i = 0; i < this.CommandCollection.Length; i++)
                            if (this.CommandCollection[i] != null)
                                timeout = this.CommandCollection[i].CommandTimeout;
                    }
                    return timeout;
                }
    
                set
                {
                    if (this.CommandCollection == null)
                        this.InitCommandCollection();
    
                    for (int i = 0; i < this.CommandCollection.Length; i++)
                        if (this.CommandCollection[i] != null)
                        {
                            this.CommandCollection[i].CommandTimeout = value;
                            _timeout = value;
                        }
                }
    
            }
        }
    
    }
    

提交回复
热议问题