Database.CreateCommand Method (String, Object[])

Creates and returns an IDbCommand object using the provided commandText as a composite format string (as used on Format(String, Object[])), where the format items are replaced with appropiate parameter names, and the objects in the parameters array are added to the command’s Parameters collection.

Namespace:  DbExtensions
Assembly: DbExtensions.dll

Syntax

public virtual IDbCommand CreateCommand(
	string commandText,
	params Object[] parameters
)

Parameters

commandText

Type: System.String
The command text.

parameters

Type: System.Object[]
The array of parameters to be passed to the command. Note the following behavior: If the number of objects in the array is less than the highest number identified in the command string, an exception is thrown. If the array contains objects that are not referenced in the command string, no exception is thrown. If a parameter is null, it is converted to DBNull.Value.

Return Value

Type: IDbCommand
A new IDbCommand object whose CommandText property is initialized with the commandText parameter, and whose Parameters property is initialized with the values from the parameters parameter.

Remarks

Transaction is associated with all commands created using this method.

See Also

Reference

Database Class
DbExtensions Namespace

© Max Toro Q.