SqlHelper..::..CreateCommand Method

Simplify the creation of a Sql command object by allowing a stored procedure and optional parameters to be provided

Namespace:  Core
Assembly:  Core (in Core.dll)

Syntax


public static SqlCommand CreateCommand(
	SqlConnection connection,
	string spName,
	params string[] sourceColumns
)

Parameters

connection
Type: SqlConnection
A valid SqlConnection object
spName
Type: String
The name of the stored procedure
sourceColumns
Type: array<String>[]()[][]
An array of string to be assigned as the source columns of the stored procedure parameters

Return Value

A valid SqlCommand object

Exceptions


ExceptionCondition
ArgumentNullException connection or spName

Remarks


e.g.: var command = CreateCommand(conn, "AddCustomer", "CustomerID", "CustomerName");