.NET Framework Class Library  

SqlCeDataAdapter Class

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

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

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

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

[Visual Basic]
NotInheritable Public Class SqlCeDataAdapter
   Inherits DbDataAdapter
   Implements IDbDataAdapter
[C#]
public sealed class SqlCeDataAdapter : DbDataAdapter,
   IDbDataAdapter
[C++]
public __gc __sealed class SqlCeDataAdapter : public DbDataAdapter,
   IDbDataAdapter
[JScript]
public class SqlCeDataAdapter extends DbDataAdapter implements
   IDbDataAdapter

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 SqlCeDataAdapter serves as a bridge between a DataSet and data source for retrieving and saving data. 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 will create 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 may also have the SqlCeDataAdapter create the schema of the DataSet, including primary key information, before filling it with data using FillSchema.

The SqlCeDataAdapter also 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.

Example

[Visual Basic, C#] 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 filled 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.

[Visual Basic] 
Public Sub SelectSqlCeSrvRows(dataset As DataSet, connStr As String, query As String)
    Dim conn As New SqlCeConnection(connStr)
    Dim adapter As New SqlCeDataAdapter()
    adapter.SelectCommand = New SqlCeCommand(query, conn)
    adapter.Fill(dataset)
End Sub

[C#] 
public void SelectSqlCeSrvRows(DataSet dataset,string connStr,string query) {
    SqlCeConnection conn     = new SqlCeConnection(connStr);
    SqlCeDataAdapter adapter = new SqlCeDataAdapter();
    adapter.SelectCommand    = new SqlCeCommand(query, conn);
    adapter.Fill(dataset);
}

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic 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

SqlCeDataAdapter Members | System.Data.SqlServerCe Namespace | SqlCeConnection | SqlCeCommand | DataSet | DataTable