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」內?我看到代碼中其他地方使用「使用塊」。
此代碼從哪裏來?什麼是SQLHelper? – JoshBerke 2009-06-26 20:25:00