SqlRowUpdatingEventArgsとは? わかりやすく解説

SqlRowUpdatingEventArgs クラス

RowUpdating イベントデータ提供します

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

Public NotInheritable Class
 SqlRowUpdatingEventArgs
    Inherits RowUpdatingEventArgs
Dim instance As SqlRowUpdatingEventArgs
public sealed class SqlRowUpdatingEventArgs
 : RowUpdatingEventArgs
public ref class SqlRowUpdatingEventArgs sealed
 : public RowUpdatingEventArgs
public final class SqlRowUpdatingEventArgs
 extends RowUpdatingEventArgs
public final class SqlRowUpdatingEventArgs
 extends RowUpdatingEventArgs
解説解説
使用例使用例

RowUpdating イベントと RowUpdated イベント使用する方法次の例に示します

RowUpdating イベントは、次の出力返します

イベント引数 : (command=System.Data.SqlClient.SQLCommand commandType=2 status=0)

RowUpdated イベントは、次の出力返します

イベント引数 : (command=System.Data.SqlClient.SQLCommand commandType=2 recordsAffected=1 row=System.Data.DataRow[37] status=0)

'Handler for RowUpdating event.
Private Shared Sub OnRowUpdating(sender
 As Object, e As SqlRowUpdatingEventArgs)
    PrintEventArgs(e)
End Sub 

'Handler for RowUpdated event.
Private Shared Sub OnRowUpdated(sender
 As Object, e As SqlRowUpdatedEventArgs)
    PrintEventArgs(e)
End Sub 

'Entry point which delegates to C-style main Private Function.
Public Overloads Shared
 Sub Main()
    System.Environment.ExitCode = Main(System.Environment.GetCommandLineArgs())
End Sub

Overloads Public Shared
 Function Main(args() As String)
 As Integer
    Const CONNECTION_STRING As String
 = "Persist Security Info=False;Integrated Security=SSPI;database=northwind;server=mySQLServer"
    Const SELECT_ALL As String
 = "select * from Products"
    
    'Create DataAdapter.
    Dim rAdapter As New
 SqlDataAdapter(SELECT_ALL, CONNECTION_STRING)
    
    'Create and fill DataSet (Select only first 5 rows.).
    Dim rDataSet As New
 DataSet()
    rAdapter.Fill(rDataSet, 0, 5, "Table")
    
    'Modify DataSet.
    Dim rTable As DataTable = rDataSet.Tables("Table")
    rTable.Rows(0)(1) = "new product"
    
    'Add handlers.
    AddHandler rAdapter.RowUpdating, AddressOf
 OnRowUpdating
    AddHandler rAdapter.RowUpdated, AddressOf
 OnRowUpdated
    
    'Update--this operation fires two events (RowUpdating and RowUpdated)
 for each changed row. 
    rAdapter.Update(rDataSet, "Table")
    
    'Remove handlers.
    RemoveHandler rAdapter.RowUpdating, AddressOf
 OnRowUpdating
    RemoveHandler rAdapter.RowUpdated, AddressOf
 OnRowUpdated
    Return 0
End Function 

Overloads Private Shared
 Sub PrintEventArgs(args As SqlRowUpdatingEventArgs)
    Console.WriteLine("OnRowUpdating")
    Console.WriteLine("  event args: (" & _
                    " command=" & _
                    args.Command.CommandText & _
                    " commandType=" & _
                    args.StatementType & _
                    " status=" & _
                    args.Status & _
                    ")")
End Sub 


Overloads Private Shared
 Sub PrintEventArgs(args As SqlRowUpdatedEventArgs)
    Console.WriteLine("OnRowUpdated")
    Console.WriteLine("  event args: (" & _
                    " command=" & _
                    args.Command.CommandText & _
                    " commandType=" & _
                    args.StatementType & _
                    " recordsAffected=" & _
                    args.RecordsAffected & _
                    " status=" & _
                    args.Status & _
                    ")")
End Sub 
// handler for RowUpdating event
private static void OnRowUpdating(object
 sender, SqlRowUpdatingEventArgs e) 
{
    PrintEventArgs(e);
}
 
//Handler for RowUpdated event.
private static void OnRowUpdated(object
 sender, SqlRowUpdatedEventArgs e) 
{
    PrintEventArgs(e);
}
 
public static int Main()
 
{
    const string CONNECTION_STRING = "Persist
 Security Info=False;Integrated Security=SSPI;database=northwind;server=mySQLServer";
    const string SELECT_ALL = "select
 * from Products";
 
    //Create DataAdapter.
    SqlDataAdapter rAdapter    = new SqlDataAdapter(SELECT_ALL,
 CONNECTION_STRING);
 
    //Create and fill DataSet (Select only first 5 rows.).
    DataSet rDataSet = new DataSet();
    rAdapter.Fill(rDataSet, 0, 5, "Table");
 
    //Modify DataSet.
    DataTable rTable = rDataSet.Tables["Table"];
    rTable.Rows[0][1] = "new product";
 
    //Add handlers.
    rAdapter.RowUpdating += new SqlRowUpdatingEventHandler( OnRowUpdating
 );
    rAdapter.RowUpdated += new SqlRowUpdatedEventHandler( OnRowUpdated
 );
 
    //Update--this operation fires two events (RowUpdating and RowUpdated)
 for each changed row. 
    rAdapter.Update(rDataSet, "Table");
 
    //Remove handlers.
    rAdapter.RowUpdating -= new SqlRowUpdatingEventHandler( OnRowUpdating
 );
    rAdapter.RowUpdated -= new SqlRowUpdatedEventHandler( OnRowUpdated
 );
    return 0;
}
 
private static void PrintEventArgs(SqlRowUpdatingEventArgs
 args) 
{
    Console.WriteLine("OnRowUpdating");
    Console.WriteLine("  event args: ("+
        " command=" + args.Command + 
        " commandType=" + args.StatementType + 
        " status=" + args.Status + ")");
}
 
private static void PrintEventArgs(SqlRowUpdatedEventArgs
 args) 
{
    Console.WriteLine("OnRowUpdated");
    Console.WriteLine("  event args: ("+
        " command=" + args.Command +
        " commandType=" + args.StatementType + 
        " recordsAffected=" + args.RecordsAffected + 
        " status=" + args.Status + ")");
}
継承階層継承階層
System.Object
   System.EventArgs
     System.Data.Common.RowUpdatingEventArgs
      System.Data.SqlClient.SqlRowUpdatingEventArgs
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
SqlRowUpdatingEventArgs メンバ
System.Data.SqlClient 名前空間

SqlRowUpdatingEventArgs コンストラクタ

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

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

Public Sub New ( _
    row As DataRow, _
    command As IDbCommand, _
    statementType As StatementType, _
    tableMapping As DataTableMapping _
)
Dim row As DataRow
Dim command As IDbCommand
Dim statementType As StatementType
Dim tableMapping As DataTableMapping

Dim instance As New SqlRowUpdatingEventArgs(row,
 command, statementType, tableMapping)
public SqlRowUpdatingEventArgs (
    DataRow row,
    IDbCommand command,
    StatementType statementType,
    DataTableMapping tableMapping
)
public:
SqlRowUpdatingEventArgs (
    DataRow^ row, 
    IDbCommand^ command, 
    StatementType statementType, 
    DataTableMapping^ tableMapping
)
public SqlRowUpdatingEventArgs (
    DataRow row, 
    IDbCommand command, 
    StatementType statementType, 
    DataTableMapping tableMapping
)
public function SqlRowUpdatingEventArgs (
    row : DataRow, 
    command : IDbCommand, 
    statementType : StatementType, 
    tableMapping : DataTableMapping
)

パラメータ

row

Update実行する DataRow。

command

Update 処理中に実行する IDbCommand。

statementType

実行されクエリ種類指定する StatementType 値の 1 つ

tableMapping

Update通じて送信された DataTableMapping。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
SqlRowUpdatingEventArgs クラス
SqlRowUpdatingEventArgs メンバ
System.Data.SqlClient 名前空間

SqlRowUpdatingEventArgs プロパティ


パブリック プロパティパブリック プロパティ

( プロテクト プロパティ参照)
  名前 説明
パブリック プロパティ Errors  Command実行時.NET Framework データ プロバイダ生成したエラー取得します。 ( RowUpdatingEventArgs から継承されます。)
パブリック プロパティ Row  挿入更新、または削除操作一部としてサーバー送信される DataRow を取得します。 ( RowUpdatingEventArgs から継承されます。)
パブリック プロパティ StatementType  実行する SQL ステートメント種類取得します。 ( RowUpdatingEventArgs から継承されます。)
パブリック プロパティ Status  Command プロパティの UpdateStatus を取得または設定します。 ( RowUpdatingEventArgs から継承されます。)
パブリック プロパティ TableMapping  Update通じて送信する DataTableMapping を取得します。 ( RowUpdatingEventArgs から継承されます。)
プロテクト プロパティプロテクト プロパティ
  名前 説明
プロテクト プロパティ BaseCommand  このクラスインスタンスの IDbCommand オブジェクト取得または設定します。 ( RowUpdatingEventArgs から継承されます。)
参照参照

関連項目

SqlRowUpdatingEventArgs クラス
System.Data.SqlClient 名前空間

SqlRowUpdatingEventArgs メソッド


SqlRowUpdatingEventArgs メンバ

RowUpdating イベントデータ提供します

SqlRowUpdatingEventArgs データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド SqlRowUpdatingEventArgs SqlRowUpdatingEventArgs クラス新しインスタンス初期化します。
パブリック プロパティパブリック プロパティ
( プロテクト プロパティ参照)
  名前 説明
パブリック プロパティ Errors  Command実行時.NET Framework データ プロバイダ生成したエラー取得します。(RowUpdatingEventArgs から継承されます。)
パブリック プロパティ Row  挿入更新、または削除操作一部としてサーバー送信される DataRow を取得します。(RowUpdatingEventArgs から継承されます。)
パブリック プロパティ StatementType  実行する SQL ステートメント種類取得します。(RowUpdatingEventArgs から継承されます。)
パブリック プロパティ Status  Command プロパティの UpdateStatus を取得または設定します。(RowUpdatingEventArgs から継承されます。)
パブリック プロパティ TableMapping  Update通じて送信する DataTableMapping を取得します。(RowUpdatingEventArgs から継承されます。)
プロテクト プロパティプロテクト プロパティ
  名前 説明
プロテクト プロパティ BaseCommand  このクラスインスタンスの IDbCommand オブジェクト取得または設定します。(RowUpdatingEventArgs から継承されます。)
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

SqlRowUpdatingEventArgs クラス
System.Data.SqlClient 名前空間



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

辞書ショートカット

すべての辞書の索引

「SqlRowUpdatingEventArgs」の関連用語

SqlRowUpdatingEventArgsのお隣キーワード
検索ランキング

   

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



SqlRowUpdatingEventArgsのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS