.NET Framework Class Library  

SqlCeParameterCollection Class

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

Collects all parameters relevant to a SqlCeCommand as well as their respective mappings to DataSet columns.

For a list of all members of this type, see SqlCeParameterCollection Members.

System.Object
   System.MarshalByRefObject
      System.Data.SqlServerCe.SqlCeParameterCollection

[Visual Basic]
NotInheritable Public Class SqlCeParameterCollection
   Inherits MarshalByRefObject
   Implements IDataParameterCollection, IList, ICollection, _
   IEnumerable
[C#]
public sealed class SqlCeParameterCollection : MarshalByRefObject,
   IDataParameterCollection, IList, ICollection, IEnumerable
[C++]
public __gc __sealed class SqlCeParameterCollection : public
   MarshalByRefObject, IDataParameterCollection, IList,
   ICollection,
   IEnumerable
[JScript]
public class SqlCeParameterCollection extends MarshalByRefObject
   implements IDataParameterCollection, IList, ICollection,
   IEnumerable

Thread Safety

Any public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Any instance members are not guaranteed to be thread safe.

Remarks

The number of parameters in the collection must be equal to the number of parameter placeholders within the command text. Otherwise, the .NET Compact Framework Data Provider for SQL Server CE may raise an error.

Example

[Visual Basic, C#, C++] The following example creates multiple instances of SqlCeParameter through the SqlCeParameterCollection collection within the SqlCeDataAdapter. These parameters are used to select data within the data source. Then they place the data in the DataSet. This example assumes that a DataSet and a SqlCeDataAdapter have already been created with the appropriate schema, commands, and connection.

[Visual Basic] 
Public Sub AddSqlCeParameters()
    ' ...
    ' create myDataSet and myDataAdapter
    ' ...
    myDataAdapter.SelectCommand.Parameters.Add("@CategoryName", SqlDbType.NVarChar, 80).Value = "toasters"
    myDataAdapter.SelectCommand.Parameters.Add("@SerialNum", SqlDbType.Int).Value = 239

    myDataAdapter.Fill(myDataSet)
End Sub

[C#] 
public void AddSqlCeParameters() {
    // ...
    // create myDataSet and myDataAdapter
    // ...

    myDataAdapter.SelectCommand.Parameters.Add("@CategoryName", SqlDbType.NVarChar, 80).Value = "toasters";
    myDataAdapter.SelectCommand.Parameters.Add("@SerialNum", SqlDbType.Int).Value = 239;
    myDataAdapter.Fill(myDataSet);
}

[C++] 
public:
    void AddSqlCeParameters()
    {
        // ...
        // create myDataSet and myDataAdapter
        // ...

        myDataAdapter->SelectCommand->Parameters->Add(S"@CategoryName", SqlDbType::NVarChar, 80)->Value = S"toasters";
        myDataAdapter->SelectCommand->Parameters->Add(S"@SerialNum", SqlDbType::Int)->Value = __box(239);
        myDataAdapter->Fill(myDataSet);
    }

[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

Namespace: System.Data.SqlServerCe

Platforms: .NET Compact Framework - Windows CE .NET

Assembly: System.Data.Sqlserverce (in System.Data.Sqlserverce.dll)

See Also

SqlCeParameterCollection Members | System.Data.SqlServerCe Namespace