2009-07-29 123 views

答えて

29

いいえ接続ごとではなくコマンド単位です。

編集、2013年5月

コメントで要求通り:コマンド実行のための

語ります

さらに詳しいメモ約commands and execution time outs in SQL Server (DBA.SE)。 その他のもの:What happens to an uncommitted transaction when the connection is closed?

+0

これをカバーするドキュメントへのリンクが便利です。 –

+1

@RichardEv:done – gbn

5

次の内容を参照してください: - ConnectionStringsデフォルトのコマンドタイムアウトプロパティはありません。

3

接続文字列にのみ接続タイムアウトを設定できます。クエリのタイムアウトは、通常はコマンドのタイムアウトになります。 (私たちがここで話していると仮定すると、あなたの質問から本当に分かりません)。

ただし、コンテキスト接続(コマンドラインで「context connection = true」で開いたSqlConnection)に対してコマンドを実行すると、コマンドのタイムアウトは無効になります。コードだけから

+0

ありがとうございました、その意味合いがうまくいっています接続文字列は他のクエリに使用できます –

1

namespace xxx.DsXxxTableAdapters { 
 
    partial class ZzzTableAdapter 
 
    { 
 
     public void SetTimeout(int timeout) 
 
     { 
 
      if (this.Adapter.DeleteCommand != null) { this.Adapter.DeleteCommand.CommandTimeout = timeout; } 
 
      if (this.Adapter.InsertCommand != null) { this.Adapter.InsertCommand.CommandTimeout = timeout; } 
 
      if (this.Adapter.UpdateCommand != null) { this.Adapter.UpdateCommand.CommandTimeout = timeout; } 
 
      if (this._commandCollection == null) { this.InitCommandCollection(); } 
 
      if (this._commandCollection != null) 
 
      { 
 
       foreach (System.Data.SqlClient.SqlCommand item in this._commandCollection) 
 
       { 
 
        if (item != null) 
 
        { item.CommandTimeout = timeout; } 
 
       } 
 
      } 
 
     } 
 
    } 
 
    
 
    //.... 
 
    
 
}

関連する問題