This topic has not yet been rated - Rate this topic

SqlCeDataAdapter Class

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

System.Object
  System.MarshalByRefObject
    System.ComponentModel.Component
      System.Data.Common.DataAdapter
        System.Data.Common.DbDataAdapter
          System.Data.SqlServerCe.SqlCeDataAdapter

Namespace:  System.Data.SqlServerCe
Assembly:  System.Data.SqlServerCe (in System.Data.SqlServerCe.dll)
public sealed class SqlCeDataAdapter : DbDataAdapter, 
	ICloneable

The SqlCeDataAdapter type exposes the following members.

  Name Description
Public method SqlCeDataAdapter() Initializes a new instance of the SqlCeDataAdapter class.
Public method SqlCeDataAdapter(SqlCeCommand) Initializes a new instance of the SqlCeDataAdapter class with the specified SqlCeCommand as the SelectCommand property.
Public method SqlCeDataAdapter(String, SqlCeConnection) Initializes a new instance of the SqlCeDataAdapter class with a SelectCommand and a SqlCeConnection object.
Public method SqlCeDataAdapter(String, String) Initializes a new instance of the SqlCeDataAdapter class with a SelectCommand and a connection string.
Top
  Name Description
Public property AcceptChangesDuringFill (inherited from DataAdapter)
Public property AcceptChangesDuringUpdate (inherited from DataAdapter)
Protected property CanRaiseEvents (inherited from Component)
Public property Container (inherited from Component)
Public property ContinueUpdateOnError (inherited from DataAdapter)
Public property DeleteCommand Gets or sets an SQL statement for deleting records from the data set.
Protected property DesignMode (inherited from Component)
Protected property Events (inherited from Component)
Protected property FillCommandBehavior (inherited from DbDataAdapter)
Public property FillLoadOption (inherited from DataAdapter)
Public property InsertCommand Gets or sets an SQL statement used to insert new records into the data source.
Public property MissingMappingAction (inherited from DataAdapter)
Public property MissingSchemaAction (inherited from DataAdapter)
Public property ReturnProviderSpecificTypes (inherited from DataAdapter)
Public property SelectCommand Gets or sets an SQL statement used to select records in the data source.
Public property Site (inherited from Component)
Public property TableMappings (inherited from DataAdapter)
Public property UpdateBatchSize (inherited from DbDataAdapter)
Public property UpdateCommand Gets or sets an SQL statement used to update records in the data source.
Top
  Name Description
Protected method AddToBatch (inherited from DbDataAdapter)
Protected method ClearBatch (inherited from DbDataAdapter)
Protected method CloneInternals Obsolete. (inherited from DataAdapter)
Public method CreateObjRef (inherited from MarshalByRefObject)
Protected method CreateRowUpdatedEvent (inherited from DbDataAdapter)
Protected method CreateRowUpdatingEvent (inherited from DbDataAdapter)
Protected method CreateTableMappings (inherited from DataAdapter)
Public method Dispose() Disposes the current instance.
Protected method Dispose(Boolean) (inherited from DbDataAdapter)
Public method Equals (inherited from Object)
Protected method ExecuteBatch (inherited from DbDataAdapter)
Public method Fill(DataSet) (inherited from DbDataAdapter)
Public method Fill(DataTable) (inherited from DbDataAdapter)
Public method Fill(DataSet, String) (inherited from DbDataAdapter)
Protected method Fill(DataTable, IDataReader) (inherited from DataAdapter)
Public method Fill(Int32, Int32, DataTable[]) (inherited from DbDataAdapter)
Protected method Fill(DataTable, IDbCommand, CommandBehavior) (inherited from DbDataAdapter)
Public method Fill(DataSet, Int32, Int32, String) (inherited from DbDataAdapter)
Protected method Fill(DataTable[], IDataReader, Int32, Int32) (inherited from DataAdapter)
Protected method Fill(DataTable[], Int32, Int32, IDbCommand, CommandBehavior) (inherited from DbDataAdapter)
Protected method Fill(DataSet, String, IDataReader, Int32, Int32) (inherited from DataAdapter)
Protected method Fill(DataSet, Int32, Int32, String, IDbCommand, CommandBehavior) (inherited from DbDataAdapter)
Public method FillSchema(DataTable, SchemaType) (inherited from DbDataAdapter)
Public method FillSchema(DataSet, SchemaType) (inherited from DbDataAdapter)
Public method FillSchema(DataSet, SchemaType, String) (inherited from DbDataAdapter)
Protected method FillSchema(DataTable, SchemaType, IDataReader) (inherited from DataAdapter)
Protected method FillSchema(DataTable, SchemaType, IDbCommand, CommandBehavior) (inherited from DbDataAdapter)
Protected method FillSchema(DataSet, SchemaType, String, IDataReader) (inherited from DataAdapter)
Protected method FillSchema(DataSet, SchemaType, IDbCommand, String, CommandBehavior) (inherited from DbDataAdapter)
Protected method Finalize (inherited from Component)
Protected method GetBatchedParameter (inherited from DbDataAdapter)
Protected method GetBatchedRecordsAffected (inherited from DbDataAdapter)
Public method GetFillParameters (inherited from DbDataAdapter)
Public method GetHashCode (inherited from Object)
Public method GetLifetimeService (inherited from MarshalByRefObject)
Protected method GetService (inherited from Component)
Public method GetType (inherited from Object)
Protected method HasTableMappings (inherited from DataAdapter)
Protected method InitializeBatching (inherited from DbDataAdapter)
Public method InitializeLifetimeService (inherited from MarshalByRefObject)
Protected method MemberwiseClone() (inherited from Object)
Protected method MemberwiseClone(Boolean) (inherited from MarshalByRefObject)
Protected method OnFillError (inherited from DataAdapter)
Protected method OnRowUpdated (inherited from DbDataAdapter)
Protected method OnRowUpdating (inherited from DbDataAdapter)
Public method ResetFillLoadOption (inherited from DataAdapter)
Public method ShouldSerializeAcceptChangesDuringFill (inherited from DataAdapter)
Public method ShouldSerializeFillLoadOption (inherited from DataAdapter)
Protected method ShouldSerializeTableMappings (inherited from DataAdapter)
Protected method TerminateBatching (inherited from DbDataAdapter)
Public method ToString (inherited from Component)
Public method Update(DataSet) (inherited from DbDataAdapter)
Public method Update(DataRow[]) (inherited from DbDataAdapter)
Public method Update(DataTable) (inherited from DbDataAdapter)
Public method Update(DataSet, String) (inherited from DbDataAdapter)
Protected method Update(DataRow[], DataTableMapping) (inherited from DbDataAdapter)
Top
  Name Description
Public event Disposed (inherited from Component)
Public event FillError (inherited from DataAdapter)
Public event RowUpdated Occurs 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 event RowUpdating Occurs 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.
Top
  Name Description
Explicit interface implemetation Private method ICloneable.Clone For a description of this member, see ICloneable.Clone().
Explicit interface implemetation Private property IDbDataAdapter.DeleteCommand (inherited from DbDataAdapter)
Explicit interface implemetation Private property IDbDataAdapter.InsertCommand (inherited from DbDataAdapter)
Explicit interface implemetation Private property IDbDataAdapter.SelectCommand (inherited from DbDataAdapter)
Explicit interface implemetation Private property IDataAdapter.TableMappings (inherited from DataAdapter)
Explicit interface implemetation Private property IDbDataAdapter.UpdateCommand (inherited from DbDataAdapter)
Top

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.

try
{
    string strDataSource =
        @"Data Source = C:\Program Files\" +
        @"Microsoft SQL Server Compact Edition\v3.5\Samples\" +
        @"Northwind.sdf";
    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
    //
    adp.Fill(ds);

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


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.
Did you find this helpful?
(1500 characters remaining)