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

Namespace: CodeSmith.Engine
Assembly: CodeSmith.Engine (in CodeSmith.Engine.dll) Version: 6.0.0.0 (7.0.0.15127)

Syntax

C#
public virtual IDbCommand CreateCommand(
	IDbConnection connection,
	string spName,
	params string[] sourceColumns
)
Visual Basic
Public Overridable Function CreateCommand ( 
	connection As IDbConnection,
	spName As String,
	ParamArray sourceColumns As String()
) As IDbCommand

Parameters

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

Return Value

Type: IDbCommand
A valid IDbCommand object

Examples

 Copy imageCopy
IDbCommand command = helper.CreateCommand(conn, "AddCustomer", "CustomerID", "CustomerName");

Exceptions

ExceptionCondition
System..::..ArgumentNullExceptionThrown if spName is null
System..::..ArgumentNullExceptionThrown if connection is null

See Also