【发布时间】:2012-04-05 07:54:44
【问题描述】:
我需要在 VB.NET 中为 ObjectDataSource 设置 commandTimeout,但我找不到任何方法。我可以在 SqlDataSource 中轻松做到这一点,但我仅限于使用 ObjectDataSource。
任何帮助将不胜感激。谢谢
【问题讨论】:
标签: vb.net objectdatasource command-timeout
我需要在 VB.NET 中为 ObjectDataSource 设置 commandTimeout,但我找不到任何方法。我可以在 SqlDataSource 中轻松做到这一点,但我仅限于使用 ObjectDataSource。
任何帮助将不胜感激。谢谢
【问题讨论】:
标签: vb.net objectdatasource command-timeout
答案来自here。
如果您使用的是强类型 TableAdapter,则需要编辑 通过设置 CommandTimeout 属性生成的代码 _commandCollection 中的命令:
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
}
【讨论】: