|
DataExtensionsCreateParameterizedCommand Method
|
Creates and returns a parameterized IDbCommand. Parameter names are embedded in the SQL statement
passed as a parameter to this method.
Namespace: GSF.DataAssembly: GSF.Core (in GSF.Core.dll) Version: 2.4.248-beta+a497a19de709fd99e2448886199a2c8824265ddf
Syntaxpublic static IDbCommand CreateParameterizedCommand(
this IDbConnection connection,
string sql,
params Object[] values
)
<ExtensionAttribute>
Public Shared Function CreateParameterizedCommand (
connection As IDbConnection,
sql As String,
ParamArray values As Object()
) As IDbCommand
public:
[ExtensionAttribute]
static IDbCommand^ CreateParameterizedCommand(
IDbConnection^ connection,
String^ sql,
... array<Object^>^ values
)
[<ExtensionAttribute>]
static member CreateParameterizedCommand :
connection : IDbConnection *
sql : string *
values : Object[] -> IDbCommand
GSF.Data.DataExtensions.CreateParameterizedCommand = function(connection, sql, ... values);
View SourceParameters
- connection IDbConnection
- The database connection.
- sql String
- The SQL statement.
- values Object
- The values for the parameters of the IDbCommand in the order that they appear in the SQL statement.
Return Value
IDbCommandThe 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
IDbConnection. 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).
ExceptionsException | Condition |
---|
ArgumentException | Number of IDbDataParameter arguments in sql expression, identified by '@', do not match number of supplied parameter values. |
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.
See Also