Freigeben über


Typed DataSet : TableAdapter CommandTimeout

If you want to set CommandTimeout  for Typed dataset's TableAdapter there is no public property exposed.You could still  either extend the partial TableAdapter class or modify the existing designer generated code to modify CommandTimeout behaviour.

For e.g. : I added DataSet1 to my windows application which has a TableAdapter called GetProductionLocationTableAdapter. GetProductionLocationTableAdapter calls a stored procedure called GetProductionLocation. To modify the default timeout setting of this select command, I modified TableAdapter constructor in DataSet1.Designer.cs as shown below.

public GetProductionLocationTableAdapter() {
            this.ClearBeforeFill = true;
            this.CommandCollection[0].CommandTimeout = 0;
        }

If you do not want to modify default dataset code, You could extend partial TableAdapter class as follow.

public partial class GetProductionLocationTableAdapter {

    public int cmdTimeout
{
get
{
return this.CommandCollection[0].CommandTimeout;
}

        set
{
this.CommandCollection[0].CommandTimeout = value;
}
}

You would  have to then call this property from the windows form/web form / class using this TableAdapter, For e.g. in my code I called this property in load event of the form.

private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'dataSet1.GetProductionLocation'    table. You can move, or remove it, as needed.
            this.getProductionLocationTableAdapter.cmdTimeout = 0;  
            this.getProductionLocationTableAdapter.Fill(this.dataSet1.GetProductionLocation);
        }

Comments

  • Anonymous
    August 24, 2008
    You've been kicked (a good thing) - Trackback from DotNetKicks.com