Assembly : System.Data (dans system.data.dll)
SyntaxePublic NotInheritable Class DataRowCollection Inherits InternalDataCollectionBase
Dim instance As DataRowCollection
public sealed class DataRowCollection : InternalDataCollectionBase
public ref class DataRowCollection sealed : public InternalDataCollectionBase
public final class DataRowCollection extends InternalDataCollectionBase
public final class DataRowCollection extends InternalDataCollectionBase
NotesDataRowCollection est un composant important de DataTable. Alors que DataColumnCollection définit le schéma de la table, DataRowCollection contient les données réelles de la table, où chaque DataRow de DataRowCollection représente une ligne unique.
Vous pouvez appeler les méthodes Add et Remove pour insérer et supprimer des objets DataRow de DataRowCollection. Vous pouvez également appeler la méthode Find pour rechercher des objets DataRow qui contiennent des valeurs spécifiques dans des colonnes clés primaires et la méthode Contains pour rechercher des mots ou des expressions dans des données de type caractères.
ExempleLe premier exemple de cette section affiche la valeur de la colonne 1 de chaque ligne dans un DataRowCollection. Le deuxième exemple ajoute une nouvelle ligne créée à l'aide de la méthode NewRow à DataRowCollection.
Private Sub ShowRows(Byval table As DataTable) ' Print the number of rows in the collection. Console.WriteLine(table.Rows.Count) Dim row As DataRow ' Print the value of columns 1 in each row For Each row In table.Rows Console.WriteLine(row(1)) Next End Sub Private Sub AddRow(ByVal table As DataTable) ' Instantiate a new row using the NewRow method. Dim newRow As DataRow = table.NewRow() ' Insert code to fill the row with values. ' Add the row to the DataRowCollection. table.Rows.Add(newRow) End Sub
private void ShowRows(DataTable table) { // Print the number of rows in the collection. Console.WriteLine(table.Rows.Count); // Print the value of columns 1 in each row foreach(DataRow row in table.Rows) { Console.WriteLine(row[1]); } } private void AddRow(DataTable table) { DataRowCollection rowCollection = table.Rows; // Instantiate a new row using the NewRow method. DataRow newRow = table.NewRow(); // Insert code to fill the row with values. // Add the row to the DataRowCollection. table.Rows.Add(newRow); }
Sécurité des threadsCe type est sécurisé pour les opérations de lecture multithread. Vous devez synchroniser les opérations d'écriture.
Plates-formesWindows 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 version
Outils (masquer)
S'enregistrer
Liste des Membres
Qui est en ligne?
FAQ