You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/data-tools/query-datasets.md
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -15,10 +15,10 @@ ms.workload:
15
15
- "data-storage"
16
16
---
17
17
# Query datasets
18
-
To search for specific records in a dataset, use the FindBy method on the DataTable, write your own foreach statement to loop over the table's Rows collection, or use [LINQ to DataSet](/dotnet/framework/data/adonet/linq-to-dataset).
18
+
To search for specific records in a dataset, use the `FindBy` method on the DataTable, write your own foreach statement to loop over the table's Rows collection, or use [LINQ to DataSet](/dotnet/framework/data/adonet/linq-to-dataset).
19
19
20
20
## Dataset case sensitivity
21
-
Within a dataset, table and column names are case-insensitive by default — that is, a table in a dataset called "Customers" can also be referred to as "customers." This matches the naming conventions in many databases, including SQL Server. In SQL Server, the default behavior is that the names of data elements cannot be distinguished only by case.
21
+
Within a dataset, table and column names are case-insensitive by default — that is, a table in a dataset called "Customers" can also be referred to as "customers." This matches the naming conventions in many databases, including SQL Server. In SQL Server, the default behavior is that the names of data elements cannot be distinguished only by case.
22
22
23
23
> [!NOTE]
24
24
> Unlike datasets, XML documents are case-sensitive, so the names of data elements defined in schemas are case-sensitive. For example, schema protocol allows the schema to define a table called "Customers" and a different table called "customers." This can result in name collisions when a schema that contains elements that differ only by case is used to generate a dataset class.
@@ -59,7 +59,7 @@ Case sensitivity, however, can be a factor in how data is interpreted within the
59
59
## Access related records
60
60
When tables in a dataset are related, a <xref:System.Data.DataRelation> object can make the related records available in another table. For example, a dataset containing `Customers` and `Orders` tables can be made available.
61
61
62
-
You can use a <xref:System.Data.DataRelation> object to locate related records by calling the <xref:System.Data.DataRow.GetChildRows%2A> method of a <xref:System.Data.DataRow> in the parent table. This method returns an array of related child records. Or you can call the <xref:System.Data.DataRow.GetParentRow%2A> method of a <xref:System.Data.DataRow> in the child table. This method returns a single <xref:System.Data.DataRow> from the parent table.
62
+
You can use a <xref:System.Data.DataRelation> object to locate related records by calling the <xref:System.Data.DataRow.GetChildRows%2A> method of a <xref:System.Data.DataRow> in the parent table. This method returns an array of related child records. Or, you can call the <xref:System.Data.DataRow.GetParentRow%2A> method of a <xref:System.Data.DataRow> in the child table. This method returns a single <xref:System.Data.DataRow> from the parent table.
63
63
64
64
This page provides examples using typed datasets. For information about navigating relationships in untyped datasets, see [Navigating DataRelations](/dotnet/framework/data/adonet/dataset-datatable-dataview/navigating-datarelations).
Copy file name to clipboardExpand all lines: docs/data-tools/relationships-in-datasets.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -54,7 +54,7 @@ The rules that you can make are specified in the <xref:System.Data.Rule> enumera
54
54
|Foreign-key constraint rule|Action|
55
55
|----------------------------------|------------|
56
56
|<xref:System.Data.Rule.Cascade>|The change (update or delete) made to the parent record is also made in related records in the child table.|
57
-
|<xref:System.Data.Rule.SetNull>|Child records are not deleted, but the foreign key in the child records is set to <xref:System.DBNull>. With this setting, child records can be left as "orphans"—that is, they have no relationship to parent records. **Note:**Using this rule can result in invalid data in the child table.|
57
+
|<xref:System.Data.Rule.SetNull>|Child records are not deleted, but the foreign key in the child records is set to <xref:System.DBNull>. With this setting, child records can be left as "orphans"—that is, they have no relationship to parent records. **Note:** Using this rule can result in invalid data in the child table.|
58
58
|<xref:System.Data.Rule.SetDefault>|The foreign key in the related child records is set to its default value (as established by the column's <xref:System.Data.DataColumn.DefaultValue%2A> property).|
59
59
|<xref:System.Data.Rule.None>|No change is made to related child records. With this setting, child records can contain references to invalid parent records.|
Copy file name to clipboardExpand all lines: docs/data-tools/save-a-dataset-as-xml.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -21,11 +21,11 @@ ms.workload:
21
21
---
22
22
# Save a dataset as XML
23
23
24
-
The XML data in a dataset can be accessed by calling the available XML methods on the dataset. To save the data in XML format, you can call either the <xref:System.Data.DataSet.GetXml%2A> method or the <xref:System.Data.DataSet.WriteXml%2A> method of a <xref:System.Data.DataSet>.
24
+
Access the XML data in a dataset by calling the available XML methods on the dataset. To save the data in XML format, you can call either the <xref:System.Data.DataSet.GetXml%2A> method or the <xref:System.Data.DataSet.WriteXml%2A> method of a <xref:System.Data.DataSet>.
25
25
26
26
Calling the <xref:System.Data.DataSet.GetXml%2A> method returns a string that contains the data from all data tables in the dataset that's formatted as XML.
27
27
28
-
Calling the <xref:System.Data.DataSet.WriteXml%2A> method sends the XML-formatted data to a file that you specify.
28
+
Calling the <xref:System.Data.DataSet.WriteXml%2A> method sends the XML-formatted data to a file that you specify.
29
29
30
30
## To save the data in a dataset as XML to a variable
Copy file name to clipboardExpand all lines: docs/data-tools/save-data-back-to-the-database.md
+13-13Lines changed: 13 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -27,11 +27,11 @@ ms.workload:
27
27
28
28
The dataset is an in-memory copy of data. If you modify that data, it's a good practice to save those changes back to the database. You do this in one of three ways:
29
29
30
-
- By calling one of the Update methods of a TableAdapter
30
+
- By calling one of the `Update` methods of a TableAdapter
31
31
32
-
- By calling one of DBDirect methods of the TableAdapter
32
+
- By calling one of `DBDirect` methods of the TableAdapter
33
33
34
-
- By calling the UpdateAll method on the TableAdapterManager that Visual Studio generates for you when the dataset contains tables that are related to other tables in the dataset
34
+
- By calling the `UpdateAll` method on the TableAdapterManager that Visual Studio generates for you when the dataset contains tables that are related to other tables in the dataset
35
35
36
36
When you data bind dataset tables to controls on a Windows Form or XAML page, the data binding architecture does all the work for you.
37
37
@@ -43,7 +43,7 @@ If you're familiar with TableAdapters, you can jump directly to one of these top
43
43
|[Update data by using a TableAdapter](../data-tools/update-data-by-using-a-tableadapter.md)|How to perform updates with TableAdapters|
44
44
|[Hierarchical update](../data-tools/hierarchical-update.md)|How to perform updates from a dataset with two or more related tables|
45
45
|[Handle a concurrency exception](../data-tools/handle-a-concurrency-exception.md)|How to handle exceptions when two users attempt to change the same data in a database at the same time|
46
-
|[How to: Save data by using a transaction](../data-tools/save-data-by-using-a-transaction.md)|How to save data in a transaction using the System.Transactions namespace and a TransactionScope object|
46
+
|[How to: Save data by using a transaction](../data-tools/save-data-by-using-a-transaction.md)|How to save data in a transaction using the System.Transactions namespace and a TransactionScope object|
47
47
|[Save data in a transaction](../data-tools/save-data-in-a-transaction.md)|Walkthrough that creates a Windows Forms application to demonstrate saving data to a database inside a transaction|
48
48
|[Save data to a database (multiple tables)](../data-tools/save-data-to-a-database-multiple-tables.md)|How to edit records and save changes in multiple tables back to the database|
49
49
|[Save data from an object to a database](../data-tools/save-data-from-an-object-to-a-database.md)|How to pass data from an object that is not in a dataset to a database by using a TableAdapter DbDirect method|
@@ -52,13 +52,13 @@ If you're familiar with TableAdapters, you can jump directly to one of these top
52
52
53
53
## Two-stage updates
54
54
55
-
Updating a data source is a two-step process. The first step is to update the dataset with new records, changed records, or deleted records. If your application never sends those changes back to the data source, then you are finished with the update.
55
+
Updating a data source is a two-step process. The first step is to update the dataset with new records, changed records, or deleted records. If your application never sends those changes back to the data source, then you're finished with the update.
56
56
57
-
If you do send the changes back to the database, then a second step is required. If you aren't using data-bound controls, then you have to manually call the Update method of the same TableAdapter (or data adapter) that you used to populate the dataset. However, you can also use different adapters, for example, to move data from one data source to another or to update multiple data sources. If you aren't using data binding, and are saving changes for related tables, you have to manually instantiate a variable of the auto-generated TableAdapterManager class, and then call its UpdateAll method.
57
+
If you do send the changes back to the database, a second step is required. If you aren't using data-bound controls, you have to manually call the `Update` method of the same TableAdapter (or data adapter) that you used to populate the dataset. However, you can also use different adapters, for example, to move data from one data source to another or to update multiple data sources. If you aren't using data binding, and are saving changes for related tables, you have to manually instantiate a variable of the auto-generated `TableAdapterManager` class, and then call its `UpdateAll` method.
58
58
59
59

60
60
61
-
A dataset contains collections of tables, which contain a collections of rows. If you intend to update an underlying data source later, you must use the methods on the DataTable.DataRowCollection property when adding or removing rows. Those methods perform the change tracking that's needed for updating the data source. If you call the RemoveAt collection on the Rows property, the deletion won't be communicated back to the database.
61
+
A dataset contains collections of tables, which contain a collections of rows. If you intend to update an underlying data source later, you must use the methods on the `DataTable.DataRowCollection` property when adding or removing rows. Those methods perform the change tracking that's needed for updating the data source. If you call the `RemoveAt` collection on the Rows property, the deletion won't be communicated back to the database.
62
62
63
63
## Merge datasets
64
64
@@ -109,7 +109,7 @@ For more information about suspending events, see [Turn off constraints while fi
109
109
110
110
## Dataset update errors
111
111
112
-
When you update a record in a dataset, there is the possibility of an error. For example, you might inadvertently write data of the wrong type to a column, or data that's too long, or data that has some other integrity problem. Or you might have application-specific validation checks that can raise custom errors during any stage of an update event. For more information, see [Validate data in datasets](../data-tools/validate-data-in-datasets.md).
112
+
When you update a record in a dataset, there is the possibility of an error. For example, you might inadvertently write data of the wrong type to a column, or data that's too long, or data that has some other integrity problem. Or, you might have application-specific validation checks that can raise custom errors during any stage of an update event. For more information, see [Validate data in datasets](../data-tools/validate-data-in-datasets.md).
113
113
114
114
## Maintain information about changes
115
115
@@ -131,7 +131,7 @@ The following table details the possible values of the <xref:System.Data.DataRow
131
131
132
132
### DataRowVersion enumeration
133
133
134
-
Datasets maintain multiple versions of records. The <xref:System.Data.DataRowVersion> fields can be used when retrieving the value found in a <xref:System.Data.DataRow> using the <xref:System.Data.DataRow.Item%2A> property or the <xref:System.Data.DataRow.GetChildRows%2A> method of the <xref:System.Data.DataRow> object.
134
+
Datasets maintain multiple versions of records. The <xref:System.Data.DataRowVersion> fields are used when retrieving the value found in a <xref:System.Data.DataRow> using the <xref:System.Data.DataRow.Item%2A> property or the <xref:System.Data.DataRow.GetChildRows%2A> method of the <xref:System.Data.DataRow> object.
135
135
136
136
The following table details the possible values of the <xref:System.Data.DataRowVersion> enumeration:
137
137
@@ -215,7 +215,7 @@ You can validate data in several ways:
215
215
216
216
- In the business layer, by adding code to your application to validate data. The dataset is one place you can do this. The dataset provides some of the advantages of back-end validation — such as the ability to validate changes as column and row values are changing. For more information, see [Validate data in datasets](../data-tools/validate-data-in-datasets.md).
217
217
218
-
- In the presentation layer, by adding validation to forms. For more information, see [User Input Validation in Windows Forms](/dotnet/framework/winforms/user-input-validation-in-windows-forms).
218
+
- In the presentation layer, by adding validation to forms. For more information, see [User input validation in Windows Forms](/dotnet/framework/winforms/user-input-validation-in-windows-forms).
219
219
220
220
- In the data back end, by sending data to the data source — for example, the database — and allowing it to accept or reject the data. If you are working with a database that has sophisticated facilities for validating data and providing error information, this can be a practical approach because you can validate the data no matter where it comes from. However, this approach might not accommodate application-specific validation requirements. Additionally, having the data source validate data can result in numerous round trips to the data source, depending on how your application facilitates the resolution of validation errors raised by the back end.
221
221
@@ -244,7 +244,7 @@ Your application changes Nancy Buchanan's status to "Preferred." As a result of
244
244
245
245
Your application now calls the `Update` method to transmit the dataset to the database. The method inspects each row in turn. For the first row, the method transmits no SQL statement to the database because that row has not changed since it was originally fetched from the database.
246
246
247
-
For the second row, however, the `Update` method automatically invokes the correct data command and transmits it to the database. The specific syntax of the SQL statement depends on the dialect of SQL that's supported by the underlying data store. But the following general traits of the transmitted SQL statement are noteworthy:
247
+
For the second row, however, the `Update` method automatically invokes the correct data command and transmits it to the database. The specific syntax of the SQL statement depends on the dialect of SQL that's supported by the underlying data store. But, the following general traits of the transmitted SQL statement are noteworthy:
248
248
249
249
- The transmitted SQL statement is an UPDATE statement. The adapter knows to use an UPDATE statement because the value of the <xref:System.Data.DataRow.RowState%2A> property is <xref:System.Data.DataRowState.Modified>.
250
250
@@ -263,15 +263,15 @@ If you've used the Visual Studio tools to generate a data adapter, the `UpdateCo
263
263
264
264
The <xref:System.Data.SqlClient.SqlParameter.SourceColumn%2A?displayProperty=fullName> property of each parameter points to a column in the data table. For example, the `SourceColumn` property for the `au_id` and `Original_au_id` parameters is set to whatever column in the data table contains the author id. When the adapter's `Update` method runs, it reads the author id column from the record that's being updated and fills the values into the statement.
265
265
266
-
In an UPDATE statement, you need to specify both the new values (those that will be written to the record) as well as the old values (so that the record can be located in the database). There are therefore two parameters for each value: one for the SET clause and a different one for the WHERE clause. Both parameters read data from the record that's being updated, but they get different versions of the column value based on the parameter's <xref:System.Data.SqlClient.SqlParameter.SourceVersion> property. The parameter for the SET clause gets the current version, and the parameter for the WHERE clause gets the original version.
266
+
In an UPDATE statement, you need to specify both the new values (those that will be written to the record) as well as the old values (so that the record can be located in the database). There are, therefore, two parameters for each value: one for the SET clause and a different one for the WHERE clause. Both parameters read data from the record that's being updated, but they get different versions of the column value based on the parameter's <xref:System.Data.SqlClient.SqlParameter.SourceVersion> property. The parameter for the SET clause gets the current version, and the parameter for the WHERE clause gets the original version.
267
267
268
268
> [!NOTE]
269
269
> You can also set values in the `Parameters` collection yourself in code, which you would typically do in an event handler for the data adapter's <xref:System.Data.DataTable.RowChanging> event.
270
270
271
271
## See also
272
272
273
273
-[Dataset tools in Visual Studio](../data-tools/dataset-tools-in-visual-studio.md)
274
-
-[Create and Configure TableAdapters](create-and-configure-tableadapters.md)
274
+
-[Create and configure TableAdapters](create-and-configure-tableadapters.md)
275
275
-[Update data by using a TableAdapter](../data-tools/update-data-by-using-a-tableadapter.md)
276
276
-[Bind controls to data in Visual Studio](../data-tools/bind-controls-to-data-in-visual-studio.md)
0 commit comments