Table of Contents

Method CreateCommand

Namespace
Open.Database.Extensions
Assembly
Open.Database.Extensions.MSSqlClient.dll

CreateCommand(SqlTransaction, CommandType, string, int)

Creates a SqlCommand on the transaction's connection, enlisted in the transaction, with the command type, text, and timeout already set.

public static SqlCommand CreateCommand(this SqlTransaction transaction, CommandType type, string commandText, int secondsTimeout = 60)

Parameters

transaction SqlTransaction

The transaction to create the command from.

type CommandType

The command type: Text, StoredProcedure, or TableDirect.

commandText string

The command text, or the stored procedure name when type is StoredProcedure.

secondsTimeout int

The number of seconds to wait before the command times out. The default is 60 seconds.

Returns

SqlCommand

A new SqlCommand that the caller owns and disposes. Its Transaction is transaction.

Exceptions

ArgumentException

commandText is empty or white space.

ArgumentNullException

transaction or commandText is null.