2009-06-26 26 views
1

私はちょうどSQLHelperクラスV2のコードを閲覧していると私は気付か次SQLHelperクラス - は、ExecuteNonQueryコード変更

public static int ExecuteNonQuery(SqlTransaction transaction, CommandType commandType, string commandText, params SqlParameter[] commandParameters) 
    { 
     if(transaction == null) throw new ArgumentNullException("transaction"); 
     if(transaction != null && transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction"); 

     // Create a command and prepare it for execution 
     SqlCommand cmd = new SqlCommand(); 
     bool mustCloseConnection = false; 
     PrepareCommand(cmd, transaction.Connection, transaction, commandType, commandText, commandParameters, out mustCloseConnection); 

     // Finally, execute the command 
     int retval = cmd.ExecuteNonQuery(); 

     // Detach the SqlParameters from the command object, so they can be used again 
     cmd.Parameters.Clear(); 
     return retval; 
    } 

コマンドは、「使用Bolck」内なかった理由はありますか?私はコード内のどこかで "Using Block"の使用を見ています。

+0

このコードはどこにありますか? SQLHelperとは何ですか? – JoshBerke

+0

はい、そうです。どうして? –

答えて

0

私の推測では、それだけで余分なコードを追加しますので、そのコマンドは、機能の範囲全体で使用されているためということです。異なる開発者が異なる実装を好む

関連する問題