Share via


Add Method (String, Object)

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
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)
public SqlCeParameter Add(
    string parameterName,
    Object value
)
public:
SqlCeParameter^ Add(
    String^ parameterName, 
    Object^ value
)
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 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

SqlCeParameterCollection Members

Add Overload

System.Data.SqlServerCe Namespace