SqlCeDataAdapter コンストラクタとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > SqlCeDataAdapter コンストラクタの意味・解説 

SqlCeDataAdapter コンストラクタ (String, SqlCeConnection)

SelectCommand オブジェクトSqlCeConnection オブジェクト指定してSqlCeDataAdapter クラス新しインスタンス初期化します。

名前空間: System.Data.SqlServerCe
アセンブリ: System.Data.SqlServerCe (system.data.sqlserverce.dll 内)
構文構文

Public Sub New ( _
    selectCommandText As String, _
    selectConnection As SqlCeConnection _
)
Dim selectCommandText As String
Dim selectConnection As SqlCeConnection

Dim instance As New SqlCeDataAdapter(selectCommandText,
 selectConnection)
public SqlCeDataAdapter (
    string selectCommandText,
    SqlCeConnection selectConnection
)
public:
SqlCeDataAdapter (
    String^ selectCommandText, 
    SqlCeConnection^ selectConnection
)
public SqlCeDataAdapter (
    String selectCommandText, 
    SqlCeConnection selectConnection
)
public function SqlCeDataAdapter (
    selectCommandText : String, 
    selectConnection : SqlCeConnection
)

パラメータ

selectCommandText

SQL SELECT ステートメントである String。この文字列は、SqlCeDataAdapter の SelectCommand プロパティの CommandText として使用されます。

selectConnection

接続を表す SqlCeConnection。

解説解説

SqlCeDataAdapter実装では、SqlCeConnection開いてない場合は、接続開かれ、再び閉じられます。これは、アプリケーション複数SqlCeDataAdapter オブジェクトFill メソッド呼び出す必要がある場合効果的です。SqlCeConnection が既に開いている場合、その接続閉じるには、明示的に Close または Dispose呼び出す必要があります

SqlCeDataAdapterインスタンス作成すると、次のように読み取り/書き込みプロパティ初期値設定されます。

プロパティ

初期値

MissingMappingAction

MissingMappingAction.Passthrough

MissingSchemaAction

MissingSchemaAction.Add

これらのプロパティの値は、各プロパティ個別呼び出して変更できます

使用例使用例

コマンド文字列SqlCeConnection オブジェクト渡して SqlCeDataAdapter作成する例を次に示します

.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
SqlCeDataAdapter クラス
SqlCeDataAdapter メンバ
System.Data.SqlServerCe 名前空間
MissingMappingAction 列挙
MissingSchemaAction 列挙

SqlCeDataAdapter コンストラクタ (String, String)

SelectCommand接続文字列指定してSqlCeDataAdapter クラス新しインスタンス初期化します。

名前空間: System.Data.SqlServerCe
アセンブリ: System.Data.SqlServerCe (system.data.sqlserverce.dll 内)
構文構文

Public Sub New ( _
    selectCommandText As String, _
    selectConnectionString As String _
)
Dim selectCommandText As String
Dim selectConnectionString As String

Dim instance As New SqlCeDataAdapter(selectCommandText,
 selectConnectionString)
public SqlCeDataAdapter (
    string selectCommandText,
    string selectConnectionString
)
public:
SqlCeDataAdapter (
    String^ selectCommandText, 
    String^ selectConnectionString
)
public SqlCeDataAdapter (
    String selectCommandText, 
    String selectConnectionString
)
public function SqlCeDataAdapter (
    selectCommandText : String, 
    selectConnectionString : String
)

パラメータ

selectCommandText

SQL SELECT ステートメントである String。この文字列は、SqlCeDataAdapter の SelectCommand プロパティの CommandText として使用されます。

selectConnectionString

接続文字列

解説解説

SqlCeDataAdapterインスタンス作成すると、次のように読み取り/書き込みプロパティ初期値設定されます。

プロパティ

初期値

MissingMappingAction

MissingMappingAction.Passthrough

MissingSchemaAction

MissingSchemaAction.Add

これらのプロパティの値は、各プロパティ個別呼び出して変更できます

使用例使用例

コマンド テキスト接続文字列渡してSqlCeDataAdapter作成する例を次に示します

Public Sub Snippet5()
    ' Create DataAdapter
    '
    Dim adp As New SqlCeDataAdapter("SELECT
 * FROM products", "Data Source = MyDatabase.sdf")

    Dim cb As New SqlCeCommandBuilder(adp)

    ' Create and fill the dataset (select only first 5 rows)
    '
    Dim ds As New DataSet()
    adp.Fill(ds, 0, 5, "Table")

    ' Modify dataSet
    '
    Dim table As DataTable = ds.Tables("Table")
    table.Rows(1)("Product Name") = "Asian
 Chai"

    ' Add handlers
    '
    AddHandler adp.RowUpdating, AddressOf OnRowUpdating
    AddHandler adp.RowUpdated, AddressOf OnRowUpdated

    ' Update, this operation fires two events (RowUpdating/RowUpdated)
  
    '
    adp.Update(ds, "Table")

    ' Remove handlers
    '
    RemoveHandler adp.RowUpdating, AddressOf
 OnRowUpdating
    RemoveHandler adp.RowUpdated, AddressOf
 OnRowUpdated

End Sub 'Snippet5


Private Shared Sub OnRowUpdating(ByVal
 sender As Object, ByVal
 e As SqlCeRowUpdatingEventArgs)
    Console.WriteLine("OnRowUpdating")
    Console.WriteLine(e.Command.CommandText)
    Console.WriteLine(e.StatementType)
    Console.WriteLine(e.Status)

End Sub 'OnRowUpdating


Private Shared Sub OnRowUpdated(ByVal
 sender As Object, ByVal
 e As SqlCeRowUpdatedEventArgs)
    Console.WriteLine("OnRowUpdated")
    Console.WriteLine(e.Command.CommandText)
    Console.WriteLine(e.StatementType)
    Console.WriteLine(e.Status)

End Sub 'OnRowUpdated
public void Snippet5()
{
    // Create DataAdapter
    //
    SqlCeDataAdapter adp = new SqlCeDataAdapter(
        "SELECT * FROM products",
        "Data Source = MyDatabase.sdf");

    SqlCeCommandBuilder cb = new SqlCeCommandBuilder(adp);

    // Create and fill the dataset (select only first 5 rows)
    //
    DataSet ds = new DataSet();
    adp.Fill(ds, 0, 5, "Table");

    // Modify dataSet
    //
    DataTable table = ds.Tables["Table"];
    table.Rows[1]["Product Name"] = "Asian Chai";

    // Add handlers
    //
    adp.RowUpdating += new SqlCeRowUpdatingEventHandler(OnRowUpdating);
    adp.RowUpdated += new SqlCeRowUpdatedEventHandler(OnRowUpdated);

    // Update, this operation fires two events (RowUpdating/RowUpdated)
  
    //
    adp.Update(ds, "Table");

    // Remove handlers
    //
    adp.RowUpdating -= new SqlCeRowUpdatingEventHandler(OnRowUpdating);
    adp.RowUpdated -= new SqlCeRowUpdatedEventHandler(OnRowUpdated);
}

private static void OnRowUpdating(object
 sender, SqlCeRowUpdatingEventArgs e)
{
    Console.WriteLine("OnRowUpdating");
    Console.WriteLine(e.Command.CommandText);
    Console.WriteLine(e.StatementType);
    Console.WriteLine(e.Status);
}

private static void OnRowUpdated(object
 sender, SqlCeRowUpdatedEventArgs e)
{
    Console.WriteLine("OnRowUpdated");
    Console.WriteLine(e.Command.CommandText);
    Console.WriteLine(e.StatementType);
    Console.WriteLine(e.Status);
}
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
SqlCeDataAdapter クラス
SqlCeDataAdapter メンバ
System.Data.SqlServerCe 名前空間
MissingMappingAction 列挙
MissingSchemaAction 列挙

SqlCeDataAdapter コンストラクタ (SqlCeCommand)

SelectCommand プロパティとして SqlCeCommand指定してSqlCeDataAdapter クラス新しインスタンス初期化します。

名前空間: System.Data.SqlServerCe
アセンブリ: System.Data.SqlServerCe (system.data.sqlserverce.dll 内)
構文構文

Public Sub New ( _
    selectCommand As SqlCeCommand _
)
Dim selectCommand As SqlCeCommand

Dim instance As New SqlCeDataAdapter(selectCommand)
public SqlCeDataAdapter (
    SqlCeCommand selectCommand
)
public:
SqlCeDataAdapter (
    SqlCeCommand^ selectCommand
)
public SqlCeDataAdapter (
    SqlCeCommand selectCommand
)
public function SqlCeDataAdapter (
    selectCommand : SqlCeCommand
)

パラメータ

selectCommand

SELECT ステートメントである SqlCeCommand。この SqlCeCommand は、SqlCeDataAdapter の SelectCommand プロパティとして設定されます。

解説解説

このコンストラクタでは、selectCommand パラメータ指定した値が SelectCommand プロパティ設定されます。

SqlCeDataAdapterインスタンス作成すると、次のように読み取り/書き込みプロパティ初期値設定されます。

プロパティ

初期値

MissingMappingAction

MissingMappingAction.Passthrough

MissingSchemaAction

MissingSchemaAction.Add

これらのプロパティの値は、各プロパティ個別呼び出して変更できます

使用例使用例

SqlCeCommand オブジェクト渡して SqlCeDataAdapter作成する例を次に示します

.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
SqlCeDataAdapter クラス
SqlCeDataAdapter メンバ
System.Data.SqlServerCe 名前空間
MissingMappingAction 列挙
MissingSchemaAction 列挙

SqlCeDataAdapter コンストラクタ

SqlCeDataAdapter クラス新しインスタンス初期化します。
オーバーロードの一覧オーバーロードの一覧

名前 説明
SqlCeDataAdapter () SqlCeDataAdapter クラス新しインスタンス初期化します。

.NET Compact Framework によってサポートされています。

SqlCeDataAdapter (SqlCeCommand) SelectCommand プロパティとして SqlCeCommand を指定してSqlCeDataAdapter クラス新しインスタンス初期化します。

.NET Compact Framework によってサポートされています。

SqlCeDataAdapter (String, SqlCeConnection) SelectCommand オブジェクトと SqlCeConnection オブジェクト指定してSqlCeDataAdapter クラス新しインスタンス初期化します。

.NET Compact Framework によってサポートされています。

SqlCeDataAdapter (String, String) SelectCommand接続文字列指定してSqlCeDataAdapter クラス新しインスタンス初期化します。

.NET Compact Framework によってサポートされています。

参照参照

関連項目

SqlCeDataAdapter クラス
SqlCeDataAdapter メンバ
System.Data.SqlServerCe 名前空間
MissingMappingAction 列挙
MissingSchemaAction 列挙

SqlCeDataAdapter コンストラクタ ()

SqlCeDataAdapter クラス新しインスタンス初期化します。

名前空間: System.Data.SqlServerCe
アセンブリ: System.Data.SqlServerCe (system.data.sqlserverce.dll 内)
構文構文

Dim instance As New SqlCeDataAdapter
public SqlCeDataAdapter ()
public:
SqlCeDataAdapter ()
public SqlCeDataAdapter ()
public function SqlCeDataAdapter ()
解説解説

SqlCeDataAdapterインスタンス作成すると、次のように読み取り/書き込みプロパティ初期値設定されます。

プロパティ

初期値

MissingMappingAction

MissingMappingAction.Passthrough

MissingSchemaAction

MissingSchemaAction.Add

これらのプロパティの値は、各プロパティ個別呼び出して変更できます

使用例使用例

SqlCeDataAdapter作成し、そのプロパティ一部設定する例を次に示します

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 [Employee ID], [First Name], [Last
 Name] FROM Employees"
    adp.SelectCommand = cmd

    ' Create the InsertCommand
    '
    cmd = conn.CreateCommand()
    cmd.CommandText = "INSERT INTO Employees ([First Name],[Last
 Name]) VALUES (@first, @last)"

    Dim p As SqlCeParameter = Nothing

    p = cmd.Parameters.Add("@first", SqlDbType.NVarChar,
 10, "First Name")
    p.SourceVersion = DataRowVersion.Original

    p = cmd.Parameters.Add("@last", SqlDbType.NVarChar,
 20, "Last Name")
    p.SourceVersion = DataRowVersion.Original

    adp.InsertCommand = cmd

    ' Create the UpdateCommand
    '
    cmd = conn.CreateCommand()
    cmd.CommandText = "UPDATE Employees SET [First Name] = @first,
 " + _
        "[Last Name] = @last WHERE [Employee ID] = @employeeID"

    p = cmd.Parameters.Add("@first", SqlDbType.NVarChar,
 10, "First Name")
    p.SourceVersion = DataRowVersion.Current

    p = cmd.Parameters.Add("@last", SqlDbType.NVarChar,
 20, "Last Name")
    p.SourceVersion = DataRowVersion.Current

    p = cmd.Parameters.Add("@employeeID", SqlDbType.NVarChar,
 20, "Employee ID")
    p.SourceVersion = DataRowVersion.Original

    adp.UpdateCommand = 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)

    ' Insert some rows
    '
    ds.Tables(0).Rows.Add(New Object() {Nothing,
 "Nancy", "Smith"})
    ds.Tables(0).Rows.Add(New Object() {Nothing,
 "Joe", "Clayton"})

    ' Update some rows
    '
    ds.Tables(0).Rows(1)(1) = "David"
    ds.Tables(0).Rows(1)(2) = "Johnson"

    ' This will execute two INSERT and one UPDATE 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.InsertCommand Then
        adp.InsertCommand.Dispose()
    End If
End Try
SqlCeCommand cmd = null;
SqlCeDataAdapter adp = null;

try
{
    adp = new SqlCeDataAdapter();
    SqlCeConnection conn = new SqlCeConnection("Data Source
 = MyDatabase.sdf");

    // Create the SelectCommand
    //
    cmd = conn.CreateCommand();
    cmd.CommandText = "SELECT [Employee ID], [First Name], [Last Name] FROM
 Employees";
    adp.SelectCommand = cmd;

    // Create the InsertCommand
    //
    cmd = conn.CreateCommand();
    cmd.CommandText = "INSERT INTO Employees ([First Name],[Last Name]) VALUES
 (@first, @last)";

    SqlCeParameter p = null;

    p = cmd.Parameters.Add("@first", SqlDbType.NVarChar, 10, "First
 Name");
    p.SourceVersion = DataRowVersion.Original;

    p = cmd.Parameters.Add("@last", SqlDbType.NVarChar, 20, "Last
 Name");
    p.SourceVersion = DataRowVersion.Original;

    adp.InsertCommand = cmd;

    // Create the UpdateCommand
    //
    cmd = conn.CreateCommand();
    cmd.CommandText = "UPDATE Employees SET [First Name] = @first, " +
        "[Last Name] = @last WHERE [Employee ID] = @employeeID";

    p = cmd.Parameters.Add("@first", SqlDbType.NVarChar, 10, "First
 Name");
    p.SourceVersion = DataRowVersion.Current;

    p = cmd.Parameters.Add("@last", SqlDbType.NVarChar, 20, "Last
 Name");
    p.SourceVersion = DataRowVersion.Current;

    p = cmd.Parameters.Add("@employeeID", SqlDbType.NVarChar, 20, "Employee
 ID");
    p.SourceVersion = DataRowVersion.Original;

    adp.UpdateCommand = cmd;

    // Populate the dataset with the results from the SELECT statement
    //
    DataSet ds = new DataSet();
    adp.Fill(ds);

    // Modify the dataset
    //
    MessageBox.Show("Number of rows: " + ds.Tables[0].Rows.Count);

    // Insert some rows
    //
    ds.Tables[0].Rows.Add(new object[] { null,
 "Nancy", "Smith" });
    ds.Tables[0].Rows.Add(new object[] { null,
 "Joe", "Clayton" });

    // Update some rows
    //
    ds.Tables[0].Rows[1][1] = "David";
    ds.Tables[0].Rows[1][2] = "Johnson";

    // This will execute two INSERT and one UPDATE statements 
    //
    adp.Update(ds.Tables[0]);

    
}
catch (Exception e)
{
    MessageBox.Show(e.Message);
}
finally
{
    if (null != adp.SelectCommand) adp.SelectCommand.Dispose();
    if (null != adp.InsertCommand) adp.InsertCommand.Dispose();
}
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
SqlCeDataAdapter クラス
SqlCeDataAdapter メンバ
System.Data.SqlServerCe 名前空間
MissingMappingAction 列挙
MissingSchemaAction 列挙



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「SqlCeDataAdapter コンストラクタ」の関連用語

SqlCeDataAdapter コンストラクタのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



SqlCeDataAdapter コンストラクタのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS