How to set commandTimeout for an ObjectDataSource
-
29-05-2021 - |
题
I need to set the commandTimeout for an ObjectDataSource in VB.NET and I can't find any way of doing it. I can do this easily in SqlDataSource but I'm restricted to using an ObjectDataSource.
Any help would be greatly appreciated. Thanks
没有正确的解决方案
其他提示
Answer taken from here.
If you are using a strongly typed TableAdapter you need to edit the generated code by setting the CommandTimeout property on the command(s) in the _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
}
不隶属于 StackOverflow