Gemstone Data Library
Show/Hide TOC

# DataExtensionsCreateParameterizedCommand Method

Creates and returns a parameterized DbCommand. Parameter names are embedded in the SQL statement passed as a parameter to this method.

## Definition

Namespace: Gemstone.Data.DataExtensions
Assembly: Gemstone.Data (in Gemstone.Data.dll) Version: 1.0.156 -- Release Build+dcdaaebc8db0d076f561458ac184e317c7d68401
C#
View Source Request Example

    public static DbCommand CreateParameterizedCommand(
    	this DbConnection connection,
    	string sql,
    	params Object?[] values
    )

VB
View Source Request Example

    <ExtensionAttribute>
    Public Shared Function CreateParameterizedCommand (
    	connection As DbConnection,
    	sql As String,
    	ParamArray values As Object()
    ) As DbCommand

C++
View Source Request Example

    public:
    [ExtensionAttribute]
    static DbCommand^ CreateParameterizedCommand(
    	DbConnection^ connection,
    	String^ sql,
    	... array<Object^>^ values
    )

JavaScript
View Source Request Example

    Gemstone.Data.DataExtensions.DataExtensions.CreateParameterizedCommand = function(connection, sql, ... values);

#### Parameters

connection DbConnection
  The database connection.
sql String
  The SQL statement.
values Object
  The values for the parameters of the DbCommand in the order that they appear in the SQL statement.

#### Return Value

DbCommand
The fully populated parameterized command.

#### Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type DbConnection. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

## Remarks

This method does very rudimentary parsing of the SQL statement so parameter names should start with the '@' character and should be surrounded by either spaces, parentheses, or commas.

Do not use the same parameter name twice in the expression so that each parameter, identified by '@', will have a corresponding value.

## Exceptions

ArgumentException | Number of DbParameter arguments in sql expression, identified by '@', do not match number of supplied parameter values.

## See Also

#### Reference

DataExtensions Class
Gemstone.Data.DataExtensions Namespace