SqlRowUpdatedEventArgs, classe (System.Data.SqlClient)

Bibliothèque de classes .NET Framework 
SqlRowUpdatedEventArgs, classe 

Fournit des données pour l'événement RowUpdated.

Espace de noms : System.Data.SqlClient
Assembly : System.Data (dans system.data.dll)

SyntaxeSyntaxe


Visual Basic (Déclaration)
Public NotInheritable Class SqlRowUpdatedEventArgs
    Inherits RowUpdatedEventArgs


Visual Basic (Utilisation)
Dim instance As SqlRowUpdatedEventArgs


C#
public sealed class SqlRowUpdatedEventArgs : RowUpdatedEventArgs


C++
public ref class SqlRowUpdatedEventArgs sealed : public RowUpdatedEventArgs


J#
public final class SqlRowUpdatedEventArgs extends RowUpdatedEventArgs


JScript
public final class SqlRowUpdatedEventArgs extends RowUpdatedEventArgs
NotesNotes

L'événement RowUpdated est déclenché lorsque Update est terminé sur une ligne.

Lors de l'utilisation de Update, deux événements se produisent pour chaque ligne de données mise à jour. L'ordre d'exécution est le suivant :

  1. Les valeurs contenues dans DataRow sont déplacées vers les valeurs de paramètre.

  2. L'événement OnRowUpdating est déclenché.

  3. La commande s'exécute.

  4. Si la commande a la valeur FirstReturnedRecord, le premier résultat retourné est placé dans DataRow.

  5. Si des paramètres de sortie existent, ils sont placés dans DataRow.

  6. L'événement OnRowUpdated est déclenché.

  7. AcceptChanges est appelé.

ExempleExemple

L'exemple suivant montre comment utiliser les événements RowUpdating et RowUpdated.

L'événement RowUpdating retourne la sortie suivante :

Arguments d'événement : (command=System.Data.SqlClient.SqlCommand commandType=2 status=0)

L'événement RowUpdated retourne la sortie suivante :

Arguments d'événement : (command=System.Data.SqlClient.SqlCommand commandType=2 recordsAffected=1 row=System.Data.DataRow[37] status=0)



Visual Basic
    ' 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 connectionString As String = _
            "Integrated Security=SSPI;database=Northwind;server=MSSQL1"
        Const queryString As String = "SELECT * FROMProducts"
        
        ' create DataAdapter
        Dim adapter As New SqlDataAdapter(queryString, connectionString)
        Dim builder As SqlCommandBuilder = New SqlCommandBuilder(adapter)
        
        ' Create and fill DataSet (select only first 5 rows)
        Dim dataSet As New DataSet()
        adapter.Fill(dataSet, 0, 5, "Table")
        
        ' Modify DataSet
        Dim table As DataTable = dataSet.Tables("Table")
        table.Rows(0)(1) = "new product"
        
        ' add handlers
        AddHandler adapter.RowUpdating, AddressOf OnRowUpdating
        AddHandler adapter.RowUpdated, AddressOf OnRowUpdated
        
        ' update, this operation fires two events 
        '(RowUpdating/RowUpdated) per changed row 
        adapter.Update(dataSet, "Table")
        
        ' remove handlers
        RemoveHandler adapter.RowUpdating, AddressOf OnRowUpdating
        RemoveHandler adapter.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 
End Class 


C#
// 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 connectionString = 
              "Integrated Security=SSPI;database=Northwind;server=MSSQL1";
    const string queryString = "SELECT * FROMProducts";
 
    // create DataAdapter
    SqlDataAdapter adapter = new SqlDataAdapter(queryString, connectionString);
    SqlCommandBuilder builder = new SqlCommandBuilder(adapter);
 
    // Create and fill DataSet (select only first 5 rows)
    DataSet dataSet = new DataSet();
    adapter.Fill(dataSet, 0, 5, "Table");
 
    // Modify DataSet
    DataTable table = dataSet.Tables["Table"];
    table.Rows[0][1] = "new product";
 
    // add handlers
    adapter.RowUpdating += new SqlRowUpdatingEventHandler( OnRowUpdating );
    adapter.RowUpdated += new SqlRowUpdatedEventHandler( OnRowUpdated );
 
    // update, this operation fires two events 
    // (RowUpdating/RowUpdated) per changed row 
    adapter.Update(dataSet, "Table");
 
    // remove handlers
    adapter.RowUpdating -= new SqlRowUpdatingEventHandler( OnRowUpdating );
    adapter.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 + ")");
}
Hiérarchie d'héritageHiérarchie d'héritage
System.Object
   System.EventArgs
     System.Data.Common.RowUpdatedEventArgs
      System.Data.SqlClient.SqlRowUpdatedEventArgs
Sécurité des threadsSécurité des threads
Les membres statiques publics (Shared en Visual Basic) de ce type sont thread-safe. Il n'est pas garanti que les membres d'instance soient thread-safe.
Plates-formesPlates-formes

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile pour Pocket PC, Windows Mobile pour Smartphone, Windows Server 2003, Windows XP Édition Media Center, Windows XP Professionnel Édition x64, Windows XP SP2, Windows XP Starter Edition

Le .NET Framework ne prend pas en charge toutes les versions de chaque plate-forme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise.

Informations de versionInformations de version

.NET Framework

Prise en charge dans : 2.0, 1.1, 1.0

.NET Compact Framework

Prise en charge dans : 2.0, 1.0
Voir aussiVoir aussi

Ces informations proviennent du site de http://msdn2.microsoft.com
Source de cette page : http://msdn2.microsoft.com/fr-fr/library/system.data.sqlclient.sqlrowupdatedeventargs.aspx

Réseaux sociaux

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher les interactions avec les réseaux sociaux sur ces pages.

 

Nuage de mots clés

9 mots clés dont 0 définis manuellement (plus d'information...).

Avertissement

Cette page ne possède pas encore de mots clés manuels, ceci est donc un exemple automatique (les niveaux de pertinence sont fictifs, mais les liens sont valables). Pour tester le nuage avec une page qui contient des mots définis manuellement, vous pouvez cliquer ici.

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher le nuage de mots clés.

 

Astuce pour imprimer les couleurs des cellules de tableaux : http://www.gaudry.be/ast-rf-450.html
Aucun commentaire pour cette page

© Ce document issu de l′infobrol est enregistré sous le certificat Cyber PrInterDeposit Digital Numbertection. Enregistrement IDDN n° 5329-6538
Document créé le 30/10/06 03:46, dernière modification le Vendredi 17 Juin 2011, 12:11
Source du document imprimé : http://www.gaudry.be/dotnet-rf-system.data.sqlclient.sqlrowupdatedeventargs.html Document affiché 4 fois ce mois de Mai.
St.Gaudry©07.01.02
Outils (masquer)
||
Recherche (afficher)
Recherche :

Utilisateur (masquer)
Apparence (afficher)
Stats (afficher)
15832 documents
452 astuces.
549 niouzes.
3099 definitions.
447 membres.
8115 messages.

Document genere en :
0,58 seconde

Mises à jour :
Mises à jour du site
Citation (masquer)
Nous ne sommes nous qu'aux yeux des autres et c'est à partir du regard des autres que nous nous assumons comme nous-mêmes.

Jean-Paul Sartre [Extrait de L'être et le néant]
 
l'infobrol
Nous sommes le Jeudi 31 Mai 2012, 23:01, toutes les heures sont au format GMT+1.00 Heure, heure d'été (+1)