SqlCeParameterCollection Class
.NET Framework 3.0
Collects all parameters relevant to a SqlCeCommand as well as their respective mappings to DataSet columns.
Namespace: System.Data.SqlServerCe
Assembly: System.Data.SqlServerCe (in system.data.sqlserverce.dll)
Assembly: System.Data.SqlServerCe (in system.data.sqlserverce.dll)
'Declaration Public NotInheritable Class SqlCeParameterCollection Inherits DbParameterCollection 'Usage Dim instance As SqlCeParameterCollection
public final class SqlCeParameterCollection extends DbParameterCollection
public final class SqlCeParameterCollection extends DbParameterCollection
Not applicable.
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.
Dim cmd As SqlCeCommand = Nothing Dim adp As SqlCeDataAdapter = Nothing Try adp = New SqlCeDataAdapter() Dim conn As New SqlCeConnection("Data Source = MyDatabase.sdf") ' Create the SelectCommand ' cmd = conn.CreateCommand() cmd.CommandText = "SELECT * FROM Orders WHERE [Ship Country] = @country AND [Ship City] = @city" cmd.Parameters.Add("@country", SqlDbType.NVarChar, 15) cmd.Parameters.Add("@city", SqlDbType.NVarChar, 15) cmd.Parameters("@country").Value = "UK" cmd.Parameters("@city").Value = "London" adp.SelectCommand = cmd ' Create the DeleteCommand ' cmd = conn.CreateCommand() cmd.CommandText = "DELETE FROM Orders WHERE [Order ID] = @orderID" Dim p As SqlCeParameter = cmd.Parameters.Add("@orderID", SqlDbType.NChar, 5, "Order ID") p.SourceVersion = DataRowVersion.Original adp.DeleteCommand = cmd ' Populate the dataset with the results from the SELECT statement ' Dim ds As New DataSet() adp.Fill(ds) ' Modify the dataset ' MessageBox.Show("Number of rows: " & ds.Tables(0).Rows.Count) ' Delete some rows ' ds.Tables(0).Rows(3).Delete() ds.Tables(0).Rows(4).Delete() ' This will execute two DELETE statements ' adp.Update(ds.Tables(0)) Catch e As Exception MessageBox.Show(e.Message) Finally If Not Nothing Is adp.SelectCommand Then adp.SelectCommand.Dispose() End If If Not Nothing Is adp.DeleteCommand Then adp.DeleteCommand.Dispose() End If End Try
System.Object
System.MarshalByRefObject
System.Data.Common.DbParameterCollection
System.Data.SqlServerCe.SqlCeParameterCollection
System.MarshalByRefObject
System.Data.Common.DbParameterCollection
System.Data.SqlServerCe.SqlCeParameterCollection
Community Additions
ADD
Show: