Skip to content

Commit e195fdc

Browse files
committed
edits
1 parent 3c8ea10 commit e195fdc

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

docs/data-tools/edit-data-in-datasets.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ ms.subservice: data-tools
2323

2424
This article describes how to query and edit data in tables in .NET Framework datasets. You can edit data in data tables much like you edit the tables in any database. You can insert, update, and delete records in the table. In a data-bound form, you can specify which fields are user-editable.
2525

26-
In those cases, the data-binding infrastructure handles all the change tracking so that the changes can be sent back to the database. If you edit data programmatically, and you intend to send the changes back to the database, you must use objects and methods that do the change tracking.
26+
In those cases, the data-binding infrastructure handles all the change tracking so that the changes can be sent back to the database. If you edit data programmatically and want to send the changes back to the database, you must use objects and methods that do the change tracking.
2727

2828
In addition to changing the actual data, you can also query a <xref:System.Data.DataTable> to return specific rows of data. For example, you can query for individual rows, original or proposed versions of rows, rows that changed, or rows that contain errors.
2929

@@ -39,7 +39,7 @@ To use Visual Studio to query and edit data in .NET Framework datasets, you need
3939

4040
To edit an existing row in a <xref:System.Data.DataTable>, you need to locate the <xref:System.Data.DataRow> you want to edit, and then assign the updated values to the desired columns.
4141

42-
If you don't know the index of the row you want to edit, use the <xref:System.Data.DataRowCollection.Find> method to search by the primary key.
42+
If you don't know the index of the row you want to edit, use the `FindBy` method to search by the primary key.
4343

4444
### [C#](#tab/csharp)
4545

@@ -61,11 +61,11 @@ Once you know the row index, you can use it to access and edit the row.
6161
:::code language="vb" source="../snippets/visualbasic/VS_Snippets_VBCSharp/VbRaddataEditing/VB/Form1.vb" id="Snippet5":::
6262
---
6363

64-
## Insert or delete new rows into a dataset
64+
## Insert new rows into a dataset
6565

6666
Applications that use data-bound controls typically add new records by using the **Add New** button on a [BindingNavigator control](/dotnet/framework/winforms/controls/bindingnavigator-control-windows-forms).
6767

68-
You can also add a new record to a dataset by calling the <xref:System.Data.DataTable.NewRow%2A> method on the `DataTable`. Then, add the row to the <xref:System.Data.DataRow> collection(<xref:System.Data.DataTable.Rows%2A>).
68+
You can also add a new record to a dataset by calling the <xref:System.Data.DataTable.NewRow%2A> method on the `DataTable`. Then, add the row to the <xref:System.Data.DataRow> collection (<xref:System.Data.DataTable.Rows%2A>).
6969
### [C#](#tab/csharp)
7070

7171
:::code language="csharp" source="../snippets/csharp/VS_Snippets_VBCSharp/VbRaddataEditing/CS/Form1.cs" id="Snippet1":::
@@ -75,9 +75,9 @@ You can also add a new record to a dataset by calling the <xref:System.Data.Data
7575
:::code language="vb" source="../snippets/visualbasic/VS_Snippets_VBCSharp/VbRaddataEditing/VB/Form1.vb" id="Snippet1":::
7676
---
7777

78-
### Delete records from a data table
78+
## Delete records from a data table
7979

80-
You can delete a <xref:System.Data.DataRow> from the <xref:System.Data.DataRowCollection> by calling the <xref:System.Data.DataRowCollection.Remove%2A> method of the <xref:System.Data.DataRowCollection>, or by calling the <xref:System.Data.DataRow.Delete%2A> method of the <xref:System.Data.DataRow> object.
80+
You can delete a <xref:System.Data.DataRow> by calling the <xref:System.Data.DataRowCollection.Remove%2A> method of the <xref:System.Data.DataRowCollection>, or by calling the <xref:System.Data.DataRow.Delete%2A> method of the <xref:System.Data.DataRow> object.
8181

8282
The <xref:System.Data.DataRowCollection.Remove%2A> method removes the row from the collection. If your application doesn't need to send updates back to a data source, you can remove records by directly accessing the data row collection with <xref:System.Data.DataRowCollection.Remove%2A>.
8383

@@ -97,9 +97,7 @@ The following example shows how to call the <xref:System.Data.DataRow.Delete%2A>
9797
---
9898

9999
> [!NOTE]
100-
> If you get the count property of a <xref:System.Data.DataRowCollection>, the resulting count includes records that are marked for deletion. To get an accurate count of records that aren't marked for deletion, you can loop through the collection looking at the <xref:System.Data.DataRow.RowState%2A> property of each record. Records marked for deletion have a <xref:System.Data.DataRow.RowState%2A> of <xref:System.Data.DataRowState.Deleted>.
101-
>
102-
> Alternatively, you can create a data view of a dataset that filters based on row state and get the count property from it.
100+
> If you get the count property of a <xref:System.Data.DataRowCollection>, the resulting count includes records that are marked for deletion. To get an accurate count of records not marked for deletion, you can loop through the collection and look at the <xref:System.Data.DataRow.RowState%2A> property of each record. Records marked for deletion have a <xref:System.Data.DataRow.RowState%2A> of <xref:System.Data.DataRowState.Deleted>. Alternatively, you can create a data view of a dataset that filters based on row state and get the count property from it.
103101
104102
<a name='determine-if-there-are-changed-rows'></a>
105103
## Determine whether there are changed rows
@@ -110,9 +108,9 @@ Changes are tracked two ways in each data row:
110108

111109
- Each data row contains information related to its <xref:System.Data.DataRow.RowState%2A>, for example <xref:System.Data.DataRowState.Added>, <xref:System.Data.DataRowState.Modified>, <xref:System.Data.DataRowState.Deleted>, or <xref:System.Data.DataRowState.Unchanged>.
112110

113-
- Each changed data row contains multiple versions. The <xref:System.Data.DataRowVersion> includes the original version before changes and the current version after changes. While a change is pending, you can respond to the <xref:System.Data.DataTable.RowChanging> event, and a third proposed version is also available.
111+
- Each changed data row contains multiple versions. The <xref:System.Data.DataRowVersion> includes the original version before changes and the current version after changes. While a change is pending and you can respond to the <xref:System.Data.DataTable.RowChanging> event, a third proposed version is also available.
114112

115-
Call the <xref:System.Data.DataSet.HasChanges%2A> method of a dataset to check for changed rows. The method returns `true` if changes were made in the dataset. After determining that changes exist, you can call the `GetChanges` method of a <xref:System.Data.DataSet> or <xref:System.Data.DataTable> to return a set of changed rows.
113+
To check for changed rows, call the <xref:System.Data.DataSet.HasChanges%2A> method of a dataset. The method returns `true` if changes were made in the dataset. After determining that changes exist, you can call the `GetChanges` method of a <xref:System.Data.DataSet> or <xref:System.Data.DataTable> to return a set of changed rows.
116114

117115
The following example shows how to check the return value from the <xref:System.Data.DataSet.HasChanges%2A> method to detect whether there are any changed rows in `NorthwindDataset1`.
118116

@@ -127,7 +125,7 @@ The following example shows how to check the return value from the <xref:System.
127125

128126
## Determine the type of changes
129127

130-
You can also check to see what type of changes were made in a dataset by passing a value from the <xref:System.Data.DataRowState> enumeration to the <xref:System.Data.DataSet.HasChanges%2A> method.
128+
You can check to see what type of changes were made in a dataset by passing a value from the <xref:System.Data.DataRowState> enumeration to the <xref:System.Data.DataSet.HasChanges%2A> method.
131129

132130
The following example shows how to check the `NorthwindDataset1` dataset to determine whether any new rows were added.
133131

0 commit comments

Comments
 (0)