Export (0) Print
Expand All

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)

[ObsoleteAttribute("Add(String parameterName, Object value) has been deprecated.  Use AddWithValue(String parameterName, Object value).", 
	false)]
public SqlCeParameter Add(
	string parameterName,
	Object value
)

Parameters

parameterName
Type: System.String
The name of the parameter.
value
Type: System.Object
The Object value of the SqlCeParameter to add to the collection.

Return Value

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

ExceptionCondition
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.

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.

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

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


Show:
© 2015 Microsoft