System.Data.SqlClient Namespace SqlParameterCollection Class
Adds an SqlParameter with the specified name and value to the parameters collection.
[ VB ]
Overloads Public Function Add ( _
ByVal parameterName As String, _
ByVal value As Object _
) As SqlParameter
[ C# ]
public SqlParameter Add (
string parameterName,
Object value
);
[ C++ ]
public: SqlParameter* Add (
String* parameterName,
Object* value
);
[ JScript ]
public function Add (
parameterName : String,
value : Object
) : SqlParameter;
- parameterName
- The name of the parameter.
- value
- The parameter's value.
The newly created SqlParameter.
When you specify an Object in the value parameter, the SqlDbType is inferred from the .NET Framework type of the Object.
The following example adds a new SqlParameter using this constructor.
SqlCommand cmd = new SqlCommand ( null, conn );
cmd.CommandText = "Insert into Categories ( CategoryName ) values ( @CategoryName ) ";
cmd.Parameters.Add ( "@CategoryName", "Beverages" );
Dim cmd As New SqlCommand ( null, conn )
cmd.CommandText = "Insert into Categories ( CategoryName ) values ( @CategoryName ) "
cmd.Parameters.Add ( "@CategoryName", "Beverages" ) |
|
C# |
VB |
SqlParameterCollection Members SqlParameterCollection.Add Overload List Value