1
我需要在VB.NET中設置一個ObjectDataSource的commandTimeout,我找不到任何方法。我可以在SqlDataSource中輕鬆完成,但我僅限於使用ObjectDataSource。如何設置一個ObjectDataSource的commandTimeout
任何幫助將不勝感激。謝謝
我需要在VB.NET中設置一個ObjectDataSource的commandTimeout,我找不到任何方法。我可以在SqlDataSource中輕鬆完成,但我僅限於使用ObjectDataSource。如何設置一個ObjectDataSource的commandTimeout
任何幫助將不勝感激。謝謝
答案取自here。
如果您使用的是強類型的TableAdapter你需要通過設置在_commandCollection的 指令(S)將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
}