Share via


SqlCeParameterCollection.Add Method (String, Object)

Note: This API is now obsolete.

Adds a SqlCeParameter to the SqlCeParameterCollection given the parameter name and value.

Namespace:  System.Data.SqlServerCe
Assembly:  System.Data.SqlServerCe (in System.Data.SqlServerCe.dll)

Syntax

'Declaration
<ObsoleteAttribute("Add(String parameterName, Object value) has been deprecated.  Use AddWithValue(String parameterName, Object value).",  _
    False)> _
Public Function Add ( _
    parameterName As String, _
    value As Object _
) As SqlCeParameter
'Usage
Dim instance As SqlCeParameterCollection
Dim parameterName As String
Dim value As Object
Dim returnValue As SqlCeParameter

returnValue = instance.Add(parameterName, _
    value)
[ObsoleteAttribute("Add(String parameterName, Object value) has been deprecated.  Use AddWithValue(String parameterName, Object value).", 
    false)]
public SqlCeParameter Add(
    string parameterName,
    Object value
)
[ObsoleteAttribute(L"Add(String parameterName, Object value) has been deprecated.  Use AddWithValue(String parameterName, Object value).", 
    false)]
public:
SqlCeParameter^ Add(
    String^ parameterName, 
    Object^ value
)
[<ObsoleteAttribute("Add(String parameterName, Object value) has been deprecated.  Use AddWithValue(String parameterName, Object value).", 
    false)>]
member Add : 
        parameterName:string * 
        value:Object -> SqlCeParameter 
public function Add(
    parameterName : String, 
    value : Object
) : SqlCeParameter

Parameters

Return Value

Type: System.Data.SqlServerCe.SqlCeParameter
A reference to the new SqlCeParameter object.

Exceptions

Exception Condition
InvalidCastException

The object supplied as the value parameter cannot be converted to a string. This can happen if the object is not a primitive type, SqlDbType or byte array.

Remarks

The SqlDbType of the new SqlCeParameter object is not inferred from the .NET Compact Framework type of the value parameter. The Value property of the new SqlCeParameter object is set to the string obtained from converting value parameter and the SqlDbType is set to SqlDbType.NChar.

If you want to explicitly set the SqlDbType of the parameter when it is created, you should use one of the other overloaded Add methods.

Examples

The following example adds new element to a SqlCeParameterCollection. It assumes that a SqlCeCommand has already been created.

cmd.Parameters.Add("@Description", "Beverages")
cmd.Parameters.Add("@Description", "Beverages");

See Also

Reference

SqlCeParameterCollection Class

Add Overload

System.Data.SqlServerCe Namespace