SqlCeDataAdapter クラス

DataSet へのデータの格納およびデータ ソースの更新に使用される、一連のデータ コマンドおよびデータベース接続を表します。

継承階層

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

名前空間:  System.Data.SqlServerCe
アセンブリ:  System.Data.SqlServerCe (System.Data.SqlServerCe.dll)

構文

'宣言
Public NotInheritable Class SqlCeDataAdapter _
    Inherits DbDataAdapter _
    Implements ICloneable
'使用
Dim instance As SqlCeDataAdapter
public sealed class SqlCeDataAdapter : DbDataAdapter, 
    ICloneable
public ref class SqlCeDataAdapter sealed : public DbDataAdapter, 
    ICloneable
[<SealedAttribute>]
type SqlCeDataAdapter =  
    class
        inherit DbDataAdapter
        interface ICloneable
    end
public final class SqlCeDataAdapter extends DbDataAdapter implements ICloneable

SqlCeDataAdapter 型は、以下のメンバーを公開しています。

コンストラクター

  名前 説明
パブリック メソッド SqlCeDataAdapter() SqlCeDataAdapter クラスの新しいインスタンスを初期化します。
パブリック メソッド SqlCeDataAdapter(SqlCeCommand) SelectCommand プロパティとして SqlCeCommand を指定して、SqlCeDataAdapter クラスの新しいインスタンスを初期化します。
パブリック メソッド SqlCeDataAdapter(String, SqlCeConnection) SelectCommand オブジェクトと SqlCeConnection オブジェクトを指定して、SqlCeDataAdapter クラスの新しいインスタンスを初期化します。
パブリック メソッド SqlCeDataAdapter(String, String) SelectCommand と接続文字列を指定して、SqlCeDataAdapter クラスの新しいインスタンスを初期化します。

Top

プロパティ

  名前 説明
パブリック プロパティ AcceptChangesDuringFill (DataAdapter から継承されます。)
パブリック プロパティ AcceptChangesDuringUpdate (DataAdapter から継承されます。)
プロテクト プロパティ CanRaiseEvents (Component から継承されます。)
パブリック プロパティ Container (Component から継承されます。)
パブリック プロパティ ContinueUpdateOnError (DataAdapter から継承されます。)
パブリック プロパティ DeleteCommand データ セットからレコードを削除する SQL ステートメントを取得または設定します。
プロテクト プロパティ DesignMode (Component から継承されます。)
プロテクト プロパティ Events (Component から継承されます。)
プロテクト プロパティ FillCommandBehavior (DbDataAdapter から継承されます。)
パブリック プロパティ FillLoadOption (DataAdapter から継承されます。)
パブリック プロパティ InsertCommand データ ソースに新しいレコードを挿入する SQL ステートメントを取得または設定します。
パブリック プロパティ MissingMappingAction (DataAdapter から継承されます。)
パブリック プロパティ MissingSchemaAction (DataAdapter から継承されます。)
パブリック プロパティ ReturnProviderSpecificTypes (DataAdapter から継承されます。)
パブリック プロパティ SelectCommand データ ソース内のレコードを選択する SQL ステートメントを取得または設定します。
パブリック プロパティ Site (Component から継承されます。)
パブリック プロパティ TableMappings (DataAdapter から継承されます。)
パブリック プロパティ UpdateBatchSize (DbDataAdapter から継承されます。)
パブリック プロパティ UpdateCommand データ ソース内のレコードを更新する SQL ステートメントを取得または設定します。

Top

メソッド

  名前 説明
プロテクト メソッド AddToBatch (DbDataAdapter から継承されます。)
プロテクト メソッド ClearBatch (DbDataAdapter から継承されます。)
プロテクト メソッド CloneInternals 互換性のために残されています。 (DataAdapter から継承されます。)
パブリック メソッド CreateObjRef (MarshalByRefObject から継承されます。)
プロテクト メソッド CreateRowUpdatedEvent (DbDataAdapter から継承されます。)
プロテクト メソッド CreateRowUpdatingEvent (DbDataAdapter から継承されます。)
プロテクト メソッド CreateTableMappings (DataAdapter から継承されます。)
パブリック メソッド Dispose() 現在のインスタンスを破棄します。
プロテクト メソッド Dispose(Boolean) (DbDataAdapter から継承されます。)
パブリック メソッド Equals (Object から継承されます。)
プロテクト メソッド ExecuteBatch (DbDataAdapter から継承されます。)
パブリック メソッド Fill(DataSet) (DbDataAdapter から継承されます。)
パブリック メソッド Fill(DataTable) (DbDataAdapter から継承されます。)
パブリック メソッド Fill(DataSet, String) (DbDataAdapter から継承されます。)
プロテクト メソッド Fill(DataTable, IDataReader) (DataAdapter から継承されます。)
パブリック メソッド Fill(Int32, Int32, array<DataTable[]) (DbDataAdapter から継承されます。)
プロテクト メソッド Fill(DataTable, IDbCommand, CommandBehavior) (DbDataAdapter から継承されます。)
パブリック メソッド Fill(DataSet, Int32, Int32, String) (DbDataAdapter から継承されます。)
プロテクト メソッド Fill(array<DataTable[], IDataReader, Int32, Int32) (DataAdapter から継承されます。)
プロテクト メソッド Fill(array<DataTable[], Int32, Int32, IDbCommand, CommandBehavior) (DbDataAdapter から継承されます。)
プロテクト メソッド Fill(DataSet, String, IDataReader, Int32, Int32) (DataAdapter から継承されます。)
プロテクト メソッド Fill(DataSet, Int32, Int32, String, IDbCommand, CommandBehavior) (DbDataAdapter から継承されます。)
パブリック メソッド FillSchema(DataTable, SchemaType) (DbDataAdapter から継承されます。)
パブリック メソッド FillSchema(DataSet, SchemaType) (DbDataAdapter から継承されます。)
パブリック メソッド FillSchema(DataSet, SchemaType, String) (DbDataAdapter から継承されます。)
プロテクト メソッド FillSchema(DataTable, SchemaType, IDataReader) (DataAdapter から継承されます。)
プロテクト メソッド FillSchema(DataTable, SchemaType, IDbCommand, CommandBehavior) (DbDataAdapter から継承されます。)
プロテクト メソッド FillSchema(DataSet, SchemaType, String, IDataReader) (DataAdapter から継承されます。)
プロテクト メソッド FillSchema(DataSet, SchemaType, IDbCommand, String, CommandBehavior) (DbDataAdapter から継承されます。)
プロテクト メソッド Finalize (Component から継承されます。)
プロテクト メソッド GetBatchedParameter (DbDataAdapter から継承されます。)
プロテクト メソッド GetBatchedRecordsAffected (DbDataAdapter から継承されます。)
パブリック メソッド GetFillParameters (DbDataAdapter から継承されます。)
パブリック メソッド GetHashCode (Object から継承されます。)
パブリック メソッド GetLifetimeService (MarshalByRefObject から継承されます。)
プロテクト メソッド GetService (Component から継承されます。)
パブリック メソッド GetType (Object から継承されます。)
プロテクト メソッド HasTableMappings (DataAdapter から継承されます。)
プロテクト メソッド InitializeBatching (DbDataAdapter から継承されます。)
パブリック メソッド InitializeLifetimeService (MarshalByRefObject から継承されます。)
プロテクト メソッド MemberwiseClone() (Object から継承されます。)
プロテクト メソッド MemberwiseClone(Boolean) (MarshalByRefObject から継承されます。)
プロテクト メソッド OnFillError (DataAdapter から継承されます。)
プロテクト メソッド OnRowUpdated (DbDataAdapter から継承されます。)
プロテクト メソッド OnRowUpdating (DbDataAdapter から継承されます。)
パブリック メソッド ResetFillLoadOption (DataAdapter から継承されます。)
パブリック メソッド ShouldSerializeAcceptChangesDuringFill (DataAdapter から継承されます。)
パブリック メソッド ShouldSerializeFillLoadOption (DataAdapter から継承されます。)
プロテクト メソッド ShouldSerializeTableMappings (DataAdapter から継承されます。)
プロテクト メソッド TerminateBatching (DbDataAdapter から継承されます。)
パブリック メソッド ToString (Component から継承されます。)
パブリック メソッド Update(DataSet) (DbDataAdapter から継承されます。)
パブリック メソッド Update(array<DataRow[]) (DbDataAdapter から継承されます。)
パブリック メソッド Update(DataTable) (DbDataAdapter から継承されます。)
パブリック メソッド Update(DataSet, String) (DbDataAdapter から継承されます。)
プロテクト メソッド Update(array<DataRow[], DataTableMapping) (DbDataAdapter から継承されます。)

Top

イベント

  名前 説明
パブリック イベント Disposed (Component から継承されます。)
パブリック イベント FillError (DataAdapter から継承されます。)
パブリック イベント RowUpdated Update の呼び出し中に、データ ソースに対して更新コマンドが実行された後に発生します。更新が試行されると、このイベントが発生します。
パブリック イベント RowUpdating Update の呼び出し中に、データ ソースに対して更新コマンドが実行される前に発生します。更新が試行されると、このイベントが発生します。

Top

明示的なインターフェイスの実装

  名前 説明
明示的なインターフェイスの実装プライベート メソッド ICloneable.Clone このメンバーの説明については、ICloneable.Clone() のトピックを参照してください。
明示的なインターフェイスの実装プライベート プロパティ IDbDataAdapter.DeleteCommand (DbDataAdapter から継承されます。)
明示的なインターフェイスの実装プライベート プロパティ IDbDataAdapter.InsertCommand (DbDataAdapter から継承されます。)
明示的なインターフェイスの実装プライベート プロパティ IDbDataAdapter.SelectCommand (DbDataAdapter から継承されます。)
明示的なインターフェイスの実装プライベート プロパティ IDataAdapter.TableMappings (DataAdapter から継承されます。)
明示的なインターフェイスの実装プライベート プロパティ IDbDataAdapter.UpdateCommand (DbDataAdapter から継承されます。)

Top

説明

SqlCeDataAdapter は DataSet とデータ ソースの間のブリッジとして機能します。データ ソースからのデータ取得や、データ ソースへのデータ保存に使用されます。SqlCeDataAdapter は、このブリッジを提供するために、データ ソース内のデータを DataSet に読み込む Fill、および DataSet での変更をデータ ソースに送り返す Update を使用します。

SqlCeDataAdapter は、DataSet にデータを読み込むときに、返されたデータを格納するテーブルおよび列が存在しない場合は、それらを作成します。ただし、MissingSchemaAction プロパティを AddWithKey に設定しない限り、暗黙的に作成されたスキーマには主キー情報は設定されません。DataSet にデータを格納する前に、FillSchema を使用して、主キー情報を含むスキーマを SqlCeDataAdapter に作成させることもできます。

SqlCeDataAdapter には、データの読み込みと更新を効率的に行うために、SelectCommandInsertCommandDeleteCommandUpdateCommandTableMappings の各プロパティが用意されています。

SqlCeDataAdapter のインスタンスを作成すると、プロパティが初期値に設定されます。これらの初期値の一覧については、SqlCeDataAdapter コンストラクターのトピックを参照してください。

使用例

SqlCeCommand、SqlCeDataAdapter、および SqlCeConnection を使用して、データ ソースからレコードを選択し、選択した行を DataSet に格納する例を次に示します。次に、格納された DataSet が返されます。このメソッドには、初期化済みの DataSet、接続文字列、および SQL SELECT ステートメントのクエリ文字列が渡されます。

Try
    Dim strDataSource As String
    strDataSource = "" & _
        "Data Source = C:\Program Files\" & _
        "Microsoft SQL Server Compact Edition\v3.5\Samples\" & _
        "Northwind.sdf"
    Dim conn As New SqlCeConnection
    conn.ConnectionString = strDataSource & ";Password='<password>'"

    Dim selectCmd As SqlCeCommand = conn.CreateCommand
    selectCmd.CommandText = "SELECT * FROM Employees"

    Dim adp As New SqlCeDataAdapter(selectCmd)

    Dim ds As 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.Item(0).Rows.Count & " rows in the DataSet!"))
Catch ds As Exception
    Console.WriteLine(ds.Message)
Finally
    Console.WriteLine(vbNewLine & vbNewLine & vbNewLine & _
                      "Press any key to continue...")
    Console.ReadKey()
End Try
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();
}

スレッド セーフ

この型の public static (Microsoft Visual Basic では Shared) のすべてのメンバーは、スレッド セーフです。インスタンス メンバーの場合は、スレッド セーフであるとは限りません。

関連項目

参照

System.Data.SqlServerCe 名前空間

SqlCeConnection

SqlCeCommand

DataSet

DataTable