Condividi tramite


SqlCeParameterCollection.Add Method (Object)

Note: This namespace, class, or member is supported only in version 1.1 of the .NET Framework.

Adds a SqlCeParameter object to the SqlCeCommand.

  [Visual Basic]
  Overloads Public Overridable Function Add( _
   ByVal 
  value
   As Object _
) As Integer Implements IList.Add
[C#]
public virtual int Add(object value
);
[C++]
public: virtual int Add(Object* value
);
[JScript]
public function Add(
   value : Object) : int;

Parameters

Return Value

The index of the new SqlCeParameter object in the collection.

Implements

IList.Add

Exceptions

Exception Type Condition
InvalidCastException The parameter passed was not a SqlCeParameter.

Example

[Visual Basic, C#, C++] The following example adds a SqlCeParameter object to a SqlCeParameterCollection. It assumes that a SqlCeCommand has already been created.

  [Visual Basic] 
Public Sub AddSqlCeParameter(ByVal cmd As SqlCeCommand)
    Dim pIndex As Integer = cmd.Parameters.Add(CType(New SqlCeParameter("Description", "Beverages"), [Object]))
End Sub

[C#] 
public void AddSqlCeParameter(SqlCeCommand cmd) {
    int pIndex = cmd.Parameters.Add((Object)new SqlCeParameter("Description", "Beverages"));
}

[C++] 
public:
    void AddSqlCeParameter(SqlCeCommand* cmd)
    {
        int pIndex = cmd->Parameters->Add((Object*)new SqlCeParameter(S"Description", S"Beverages"));
    };

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: .NET Compact Framework

.NET Framework Security:

See Also

SqlCeParameterCollection Class | SqlCeParameterCollection Members | System.Data.SqlServerCe Namespace | SqlCeParameterCollection.Add Overload List

Syntax based on .NET Framework version 1.1.
Documentation version 1.1.1.

Send comments on this topic.

© Microsoft Corporation. All rights reserved.