i have the habit to use table adapters on my projects , the problem is when it tries to execute long queries it times out. to solve the problem ,i have to add a new method to its class definition
after googling and reading msdn here is my solution
//add these codes to the dataset designer class
namespace Trial
{
public partial class myDataSet : System.Data.DataSet {
:
:
public partial class GetLongQueryTableAdapter : System.ComponentModel.Component {
//as a property
public int CommandTimeout
{
get
{
//codes here
}
set
{
foreach (System.Data.SqlClient.SqlCommand _com in CommandCollection)
{
_com.CommandTimeout = value;
}
}
}
// or as a method
public void SetCommandTimeout(int pTimeOut){
foreach (System.Data.SqlClient.SqlCommand _com in CommandCollection)
{
_com.CommandTimeout = value;
}
}
}
}
}
note : i tried creating a separate partial class of the TableAdapter but i could not access the CommandCollection . maybe someone would tell me why
: dont forget to change the value after the long query
there is another option though, you can change the query. in my case its a stored proc that returns rows im calling . i changed my approach and created a view instead.
anybody can just comment on the code. i think you have other ways/better ways to do it.
Posted
08-25-2006 4:53 AM
by
trashVin