SqlCeParameterCollection.Item Property (Int32)

Gets or sets the SqlCeParameter at the specified index.

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

public SqlCeParameter this[
	int index
] { get; set; }


Type: System.Int32
The zero-based index of the parameter to retrieve.

Property Value

Type: System.Data.SqlServerCe.SqlCeParameter
The SqlCeParameter at the specified index.


The index specified does not exist.

The Item property is an indexer to the collection. To set the properties of a specific item, you reference the item by its number or name.

The following example adds a SqlCeParameter object to SqlCeParameterCollection, and then sets the value of the first parameter (0 in the collection). This example assumes that a SqlCeCommand has already been created.

SqlCeDataAdapter da = new SqlCeDataAdapter();

SqlCeConnection conn = new SqlCeConnection("Data Source = MyDatabase.sdf");
SqlCeCommand cmd = new SqlCeCommand("SELECT * FROM Customers WHERE Country = @country", conn);

cmd.Parameters.Add("@country", SqlDbType.NVarChar, 15);
cmd.Parameters[0].Value = "UK";

da.SelectCommand = cmd;