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

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > 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 名前空間



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

辞書ショートカット

すべての辞書の索引

「SqlRowUpdatingEventArgs クラス」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS