1

我需要在 VB.NET 中为 ObjectDataSource 设置 commandTimeout,但我找不到任何方法。我可以在 SqlDataSource 中轻松做到这一点,但我仅限于使用 ObjectDataSource。

任何帮助将不胜感激。谢谢

4

1 回答 1

0

答案取自这里

如果您使用的是强类型 TableAdapter,则需要通过在 _commandCollection 中的命令上设置 CommandTimeout 属性来编辑生成的代码:

YourDataSet.Designer.cs:

[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "4.0.0.0")]
        private void InitCommandCollection() {
            this._commandCollection = new global::System.Data.SqlClient.SqlCommand[1];
            this._commandCollection[0] = new global::System.Data.SqlClient.SqlCommand();
            this._commandCollection[0].Connection = this.Connection;
            this._commandCollection[0].CommandText = "SELECT * FROM dbo.Table";
            this._commandCollection[0].CommandType = global::System.Data.CommandType.Text;
            this._commandCollection[0].CommandTimeout = 1000; //Timeout in seconds
        }
于 2017-03-08T06:56:31.000 回答