SqlCeDataAdapter Class

Represents a set of data commands and a database connection that are used to fill the DataSet and update the data source.

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

public sealed class SqlCeDataAdapter : DbDataAdapter, 

The SqlCeDataAdapter type exposes the following members.

Public methodSqlCeDataAdapter()Initializes a new instance of the SqlCeDataAdapter class.
Public methodSqlCeDataAdapter(SqlCeCommand)Initializes a new instance of the SqlCeDataAdapter class with the specified SqlCeCommand as the SelectCommand property.
Public methodSqlCeDataAdapter(String, SqlCeConnection)Initializes a new instance of the SqlCeDataAdapter class with a SelectCommand and a SqlCeConnection object.
Public methodSqlCeDataAdapter(String, String)Initializes a new instance of the SqlCeDataAdapter class with a SelectCommand and a connection string.

Public propertyAcceptChangesDuringFill (inherited from DataAdapter)
Public propertyAcceptChangesDuringUpdate (inherited from DataAdapter)
Protected propertyCanRaiseEvents (inherited from Component)
Public propertyContainer (inherited from Component)
Public propertyContinueUpdateOnError (inherited from DataAdapter)
Public propertyDeleteCommandGets or sets an SQL statement for deleting records from the data set.
Protected propertyDesignMode (inherited from Component)
Protected propertyEvents (inherited from Component)
Protected propertyFillCommandBehavior (inherited from DbDataAdapter)
Public propertyFillLoadOption (inherited from DataAdapter)
Public propertyInsertCommandGets or sets an SQL statement used to insert new records into the data source.
Public propertyMissingMappingAction (inherited from DataAdapter)
Public propertyMissingSchemaAction (inherited from DataAdapter)
Public propertyReturnProviderSpecificTypes (inherited from DataAdapter)
Public propertySelectCommandGets or sets an SQL statement used to select records in the data source.
Public propertySite (inherited from Component)
Public propertyTableMappings (inherited from DataAdapter)
Public propertyUpdateBatchSize (inherited from DbDataAdapter)
Public propertyUpdateCommandGets or sets an SQL statement used to update records in the data source.

Protected methodAddToBatch (inherited from DbDataAdapter)
Protected methodClearBatch (inherited from DbDataAdapter)
Protected methodCloneInternals Obsolete. (inherited from DataAdapter)
Public methodCreateObjRef (inherited from MarshalByRefObject)
Protected methodCreateRowUpdatedEvent (inherited from DbDataAdapter)
Protected methodCreateRowUpdatingEvent (inherited from DbDataAdapter)
Protected methodCreateTableMappings (inherited from DataAdapter)
Public methodDispose()Disposes the current instance.
Protected methodDispose(Boolean) (inherited from DbDataAdapter)
Public methodEquals (inherited from Object)
Protected methodExecuteBatch (inherited from DbDataAdapter)
Public methodFill(DataSet) (inherited from DbDataAdapter)
Public methodFill(DataTable) (inherited from DbDataAdapter)
Public methodFill(DataSet, String) (inherited from DbDataAdapter)
Protected methodFill(DataTable, IDataReader) (inherited from DataAdapter)
Public methodFill(Int32, Int32, DataTable[]) (inherited from DbDataAdapter)
Protected methodFill(DataTable, IDbCommand, CommandBehavior) (inherited from DbDataAdapter)
Public methodFill(DataSet, Int32, Int32, String) (inherited from DbDataAdapter)
Protected methodFill(DataTable[], IDataReader, Int32, Int32) (inherited from DataAdapter)
Protected methodFill(DataTable[], Int32, Int32, IDbCommand, CommandBehavior) (inherited from DbDataAdapter)
Protected methodFill(DataSet, String, IDataReader, Int32, Int32) (inherited from DataAdapter)
Protected methodFill(DataSet, Int32, Int32, String, IDbCommand, CommandBehavior) (inherited from DbDataAdapter)
Public methodFillSchema(DataTable, SchemaType) (inherited from DbDataAdapter)
Public methodFillSchema(DataSet, SchemaType) (inherited from DbDataAdapter)
Public methodFillSchema(DataSet, SchemaType, String) (inherited from DbDataAdapter)
Protected methodFillSchema(DataTable, SchemaType, IDataReader) (inherited from DataAdapter)
Protected methodFillSchema(DataTable, SchemaType, IDbCommand, CommandBehavior) (inherited from DbDataAdapter)
Protected methodFillSchema(DataSet, SchemaType, String, IDataReader) (inherited from DataAdapter)
Protected methodFillSchema(DataSet, SchemaType, IDbCommand, String, CommandBehavior) (inherited from DbDataAdapter)
Protected methodFinalize (inherited from Component)
Protected methodGetBatchedParameter (inherited from DbDataAdapter)
Protected methodGetBatchedRecordsAffected (inherited from DbDataAdapter)
Public methodGetFillParameters (inherited from DbDataAdapter)
Public methodGetHashCode (inherited from Object)
Public methodGetLifetimeService (inherited from MarshalByRefObject)
Protected methodGetService (inherited from Component)
Public methodGetType (inherited from Object)
Protected methodHasTableMappings (inherited from DataAdapter)
Protected methodInitializeBatching (inherited from DbDataAdapter)
Public methodInitializeLifetimeService (inherited from MarshalByRefObject)
Protected methodMemberwiseClone() (inherited from Object)
Protected methodMemberwiseClone(Boolean) (inherited from MarshalByRefObject)
Protected methodOnFillError (inherited from DataAdapter)
Protected methodOnRowUpdated (inherited from DbDataAdapter)
Protected methodOnRowUpdating (inherited from DbDataAdapter)
Public methodResetFillLoadOption (inherited from DataAdapter)
Public methodShouldSerializeAcceptChangesDuringFill (inherited from DataAdapter)
Public methodShouldSerializeFillLoadOption (inherited from DataAdapter)
Protected methodShouldSerializeTableMappings (inherited from DataAdapter)
Protected methodTerminateBatching (inherited from DbDataAdapter)
Public methodToString (inherited from Component)
Public methodUpdate(DataSet) (inherited from DbDataAdapter)
Public methodUpdate(DataRow[]) (inherited from DbDataAdapter)
Public methodUpdate(DataTable) (inherited from DbDataAdapter)
Public methodUpdate(DataSet, String) (inherited from DbDataAdapter)
Protected methodUpdate(DataRow[], DataTableMapping) (inherited from DbDataAdapter)

Public eventDisposed (inherited from Component)
Public eventFillError (inherited from DataAdapter)
Public eventRowUpdatedOccurs during a call to Update after an update command is executed against the data source. The attempt to update is made and then this event fires.
Public eventRowUpdatingOccurs during a call to Update before an update command is executed against the data source. The attempt to update is made, and then this event fires.

Explicit interface implemetationPrivate methodICloneable.CloneFor a description of this member, see ICloneable.Clone().
Explicit interface implemetationPrivate propertyIDbDataAdapter.DeleteCommand (inherited from DbDataAdapter)
Explicit interface implemetationPrivate propertyIDbDataAdapter.InsertCommand (inherited from DbDataAdapter)
Explicit interface implemetationPrivate propertyIDbDataAdapter.SelectCommand (inherited from DbDataAdapter)
Explicit interface implemetationPrivate propertyIDataAdapter.TableMappings (inherited from DataAdapter)
Explicit interface implemetationPrivate propertyIDbDataAdapter.UpdateCommand (inherited from DbDataAdapter)

The SqlCeDataAdapter serves as a bridge between a DataSet and data source. It is used for retrieving data from, and saving data to, the data source. The SqlCeDataAdapter provides this bridge by using Fill to load data from the data source into the DataSet, and using Update to send changes made in the DataSet back to the data source.

When the SqlCeDataAdapter fills a DataSet, it creates the necessary tables and columns for the returned data if they do not already exist. However, primary key information will not be included in the implicitly created schema unless the MissingSchemaAction property is set to AddWithKey. You can also have the SqlCeDataAdapter create the schema of the DataSet, including primary key information, before filling it with data by using FillSchema.

The SqlCeDataAdapter includes the SelectCommand, InsertCommand, DeleteCommand, UpdateCommand, and TableMappings properties to facilitate the loading and updating of data.

When you create an instance of SqlCeDataAdapter, properties are set to their initial values. For a list of these values, see the SqlCeDataAdapter constructor.

The following example uses the SqlCeCommand, SqlCeDataAdapter, and SqlCeConnection to select records from a data source and populate a DataSet with the selected rows. The populated DataSet is then returned. To accomplish this, the method is passed an initialized DataSet, a connection string, and a query string that is an SQL SELECT statement.

    string strDataSource =
        @"Data Source = C:\Program Files\" +
        @"Microsoft SQL Server Compact Edition\v3.5\Samples\" +
    SqlCeConnection conn = new SqlCeConnection();
    conn.ConnectionString = strDataSource + ";Password='<password>'";

    SqlCeCommand selectCmd = conn.CreateCommand();
    selectCmd.CommandText = "SELECT * FROM Employees";

    SqlCeDataAdapter adp = new SqlCeDataAdapter(selectCmd);

    DataSet ds = new DataSet();

    // Note: Fill will leave the connection in its original state;
    // In this case, the connection was closed so it will be left closed

    Console.WriteLine("The SqlCeDataAdapter succesfully filled " +
        ds.Tables[0].Rows.Count + " rows in the DataSet!");
catch (Exception ex)
    Console.WriteLine("\n\n\nPress any key to continue...");

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