Skip to content

Commit 6f0fe07

Browse files
authored
Merge pull request #678 from MicrosoftDocs/gewarren-datatoolsfixes
Removed leading space to fix Note box for VS settings note.
2 parents 4c17614 + 2523883 commit 6f0fe07

21 files changed

+119
-146
lines changed

docs/data-tools/add-code-to-datasets-in-n-tier-applications.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ ms.topic: "article"
99
dev_langs:
1010
- "VB"
1111
- "CSharp"
12-
- "C++"
13-
- "aspx"
1412
helpviewer_keywords:
1513
- "n-tier applications, extending datasets"
1614
ms.assetid: d43c2ccd-4902-43d8-b1a8-d10ca5d3210c
@@ -39,10 +37,10 @@ You can extend the functionality of a dataset by creating a partial class file f
3937

4038
The code that defines a dataset is generated every time changes are made to the dataset definition (in the typed dataset). This code is also generated when you make changes during the running of any wizard that modifies the configuration of a dataset. To prevent your code from being deleted during the regeneration of a dataset, add code to the dataset's partial class file.
4139

42-
By default, after you separate the dataset and `TableAdapter` code, the result is a discrete class file in each project. The original project has a file named *DatasetName*.Designer.vb (or *DatasetName*.Designer.cs) that contains the `TableAdapter` code. The project that's designated in the **Dataset Project** property has a file that's named *DatasetName*.DataSet.Designer.vb (or *DatasetName*.DataSet.Designer.cs).This file contains the dataset code.
40+
By default, after you separate the dataset and TableAdapter code, the result is a discrete class file in each project. The original project has a file named *DatasetName*.Designer.vb (or *DatasetName*.Designer.cs) that contains the TableAdapter code. The project that's designated in the **Dataset Project** property has a file that's named *DatasetName*.DataSet.Designer.vb (or *DatasetName*.DataSet.Designer.cs).This file contains the dataset code.
4341

4442
> [!NOTE]
45-
> When you separate datasets and `TableAdapter`s (by setting the **DataSet Project** property), existing partial dataset classes in the project won't be moved automatically. Existing dataset partial classes must be moved manually to the dataset project.
43+
> When you separate datasets and TableAdapters (by setting the **DataSet Project** property), existing partial dataset classes in the project won't be moved automatically. Existing dataset partial classes must be moved manually to the dataset project.
4644
4745
> [!NOTE]
4846
> When validation code needs to be added, the typed dataset provides functionality for generating <xref:System.Data.DataTable.ColumnChanging> and <xref:System.Data.DataTable.RowChanging> event handlers. For more information, see [Add validation to an n-tier dataset](../data-tools/add-validation-to-an-n-tier-dataset.md).
@@ -66,8 +64,7 @@ You can extend the functionality of a dataset by creating a partial class file f
6664
' Add code here to add functionality
6765
' to the CustomersDataTable.
6866
End Class
69-
```
70-
67+
```
7168
```csharp
7269
partial class CustomersDataTable
7370
{

docs/data-tools/add-code-to-tableadapters-in-n-tier-applications.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ ms.topic: "article"
99
dev_langs:
1010
- "VB"
1111
- "CSharp"
12-
- "C++"
13-
- "aspx"
1412
helpviewer_keywords:
1513
- "TableAdapters, n-tier applications"
1614
- "n-tier applications, extending TableAdapters"
@@ -36,27 +34,27 @@ translation.priority.mt:
3634
- "tr-tr"
3735
---
3836
# Add code to TableAdapters in n-tier applications
39-
You can extend the functionality of a `TableAdapter` by creating a partial class file for the `TableAdapter` and adding code to it (instead of adding code to the *DatasetName*.DataSet.Designer file). Partial classes enable code for a specific class to be divided among multiple physical files. For more information, see [Partial](/dotnet/visual-basic/language-reference/modifiers/partial) or [partial (Type)](/dotnet/csharp/language-reference/keywords/partial-type).
37+
You can extend the functionality of a TableAdapter by creating a partial class file for the TableAdapter and adding code to it (instead of adding code to the *DatasetName*.DataSet.Designer file). Partial classes enable code for a specific class to be divided among multiple physical files. For more information, see [Partial](/dotnet/visual-basic/language-reference/modifiers/partial) or [partial (Type)](/dotnet/csharp/language-reference/keywords/partial-type).
4038

41-
The code that defines a `TableAdapter` is generated every time changes are made to the `TableAdapter` in the dataset. This code is also generated when changes are made during the running of any wizard that modifies the configuration of the `TableAdapter`. To prevent your code from being deleted during the regeneration of a `TableAdapter`, add code to the partial class file of the `TableAdapter`.
39+
The code that defines a TableAdapter is generated every time changes are made to the TableAdapter in the dataset. This code is also generated when changes are made during the running of any wizard that modifies the configuration of the TableAdapter. To prevent your code from being deleted during the regeneration of a TableAdapter, add code to the partial class file of the TableAdapter.
4240

43-
By default, after you separate the dataset and `TableAdapter` code, the result is a discrete class file in each project. The original project has a file named *DatasetName*.Designer.vb (or *DatasetName*.Designer.cs) that contains the `TableAdapter` code. The project that's designated in the **Dataset Project** property has a file named *DatasetName*.DataSet.Designer.vb (or *DatasetName*.DataSet.Designer.cs) that contains the dataset code.
41+
By default, after you separate the dataset and TableAdapter code, the result is a discrete class file in each project. The original project has a file named *DatasetName*.Designer.vb (or *DatasetName*.Designer.cs) that contains the TableAdapter code. The project that's designated in the **Dataset Project** property has a file named *DatasetName*.DataSet.Designer.vb (or *DatasetName*.DataSet.Designer.cs) that contains the dataset code.
4442

4543
> [!NOTE]
46-
> When you separate datasets and `TableAdapter`s (by setting the **DataSet Project** property), existing partial dataset classes in the project will not be moved automatically. Existing dataset partial classes must be moved manually to the dataset project.
44+
> When you separate datasets and TableAdapters (by setting the **DataSet Project** property), existing partial dataset classes in the project will not be moved automatically. Existing partial dataset classes must be moved manually to the dataset project.
4745
4846
> [!NOTE]
49-
> The datasetprovides functionality for generating <xref:System.Data.DataTable.ColumnChanging> and <xref:System.Data.DataTable.RowChanging> event handlers when validation is needed. For more information, see [Add validation to an n-tier dataset](../data-tools/add-validation-to-an-n-tier-dataset.md).
47+
> The dataset provides functionality for generating <xref:System.Data.DataTable.ColumnChanging> and <xref:System.Data.DataTable.RowChanging> event handlers when validation is needed. For more information, see [Add validation to an n-tier dataset](../data-tools/add-validation-to-an-n-tier-dataset.md).
5048
51-
[!INCLUDE[note_settings_general](../data-tools/includes/note_settings_general_md.md)]
49+
[!INCLUDE[note_settings_general](../data-tools/includes/note_settings_general_md.md)]
5250

5351
### To add user code to a TableAdapter in an n-tier application
5452

5553
1. Locate the project that contains the .xsd file.
5654

5755
2. Double click the **.xsd** file to open the **Dataset Designer**.
5856

59-
3. Right-click the `TableAdapter` that you want to add code to, and then select **View Code**.
57+
3. Right-click the TableAdapter that you want to add code to, and then select **View Code**.
6058

6159
A partial class is created and opens in the Code Editor.
6260

docs/data-tools/add-validation-to-an-n-tier-dataset.md

Lines changed: 28 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ ms.topic: "article"
99
dev_langs:
1010
- "VB"
1111
- "CSharp"
12-
- "C++"
13-
- "aspx"
1412
helpviewer_keywords:
1513
- "n-tier applications, validating"
1614
- "validation [Visual Basic], n-tier data applications"
@@ -39,15 +37,15 @@ translation.priority.mt:
3937
# Add validation to an n-tier dataset
4038
Adding validation to a dataset that is separated into an n-tier solution is basically the same as adding validation to a single-file dataset (a dataset in a single project). The suggested location for performing validation on data is during the <xref:System.Data.DataTable.ColumnChanging> and/or <xref:System.Data.DataTable.RowChanging> events of a data table.
4139

42-
The datasetprovides the functionality to create partial classes to which you can add user code to column- and row- changing events of the data tables in the dataset. For more information about adding code to a dataset in an n-tier solution, see [Add code to datasets in n-tier applications](../data-tools/add-code-to-datasets-in-n-tier-applications.md), and [Add code to TableAdapters in n-tier applications](../data-tools/add-code-to-tableadapters-in-n-tier-applications.md). For more information about partial classes, see [How to: Split a Class into Partial Classes (Class Designer)](../ide/how-to-split-a-class-into-partial-classes-class-designer.md) or [Partial Classes and Methods](/dotnet/csharp/programming-guide/classes-and-structs/partial-classes-and-methods).
40+
The dataset provides the functionality to create partial classes to which you can add user code to column- and row-changing events of the data tables in the dataset. For more information about adding code to a dataset in an n-tier solution, see [Add code to datasets in n-tier applications](../data-tools/add-code-to-datasets-in-n-tier-applications.md), and [Add code to TableAdapters in n-tier applications](../data-tools/add-code-to-tableadapters-in-n-tier-applications.md). For more information about partial classes, see [How to: Split a Class into Partial Classes (Class Designer)](../ide/how-to-split-a-class-into-partial-classes-class-designer.md) or [Partial Classes and Methods](/dotnet/csharp/programming-guide/classes-and-structs/partial-classes-and-methods).
4341

4442
> [!NOTE]
45-
> When you separate datasets from TableAdapters (by setting the **DataSet Project** property), existing partial dataset classes in the project won't be moved automatically. Existing dataset partial classes must be moved manually to the dataset project.
43+
> When you separate datasets from TableAdapters (by setting the **DataSet Project** property), existing partial dataset classes in the project won't be moved automatically. Existing partial dataset classes must be moved manually to the dataset project.
4644
4745
> [!NOTE]
48-
> The Dataset Designer does not automatically create event handlers in C# for the <xref:System.Data.DataTable.ColumnChanging> and <xref:System.Data.DataTable.RowChanging> events. You have to manually create an event handler and hook up the event handler to the underlying event. The following procedures describe how to create the required event handlers in both Visual Basic and C#.
46+
> The dataset Designer does not automatically create event handlers in C# for the <xref:System.Data.DataTable.ColumnChanging> and <xref:System.Data.DataTable.RowChanging> events. You have to manually create an event handler and hook up the event handler to the underlying event. The following procedures describe how to create the required event handlers in both Visual Basic and C#.
4947
50-
## Validatechanges to individual columns
48+
## Validate changes to individual columns
5149
Validate values in individual columns by handling the <xref:System.Data.DataTable.ColumnChanging> event. The <xref:System.Data.DataTable.ColumnChanging> event is raised when a value in a column is modified. Create an event handler for the <xref:System.Data.DataTable.ColumnChanging> event by double-clicking the desired column on the **Dataset Designer**.
5250

5351
The first time that you double-click a column, the designer generates an event handler for the <xref:System.Data.DataTable.ColumnChanging> event. An `If...Then` statement is also created that tests for the specific column. For example, the following code is generated when you double-click the RequiredDate column on the Northwind Orders table:
@@ -63,11 +61,9 @@ End Sub
6361
> [!NOTE]
6462
> In C# projects, the Dataset Designer only creates partial classes for the dataset and individual tables in the dataset. The Dataset Designer does not automatically create event handlers for the <xref:System.Data.DataTable.ColumnChanging> and <xref:System.Data.DataTable.RowChanging> events in C# like it does in Visual Basic. In C# projects, you have to manually construct a method to handle the event and hook up the method to the underlying event. The following procedure provides the steps to create the required event handlers in both Visual Basic and C#.
6563
66-
[!INCLUDE[note_settings_general](../data-tools/includes/note_settings_general_md.md)]
67-
6864
#### To add validation during changes to individual column values
6965

70-
1. Open the dataset in The dataset by double-clicking the **.xsd** file in **Solution Explorer**. For more information, see [Walkthrough: Creating a Dataset in the Dataset Designer](walkthrough-creating-a-dataset-with-the-dataset-designer.md).
66+
1. Open the dataset by double-clicking the **.xsd** file in **Solution Explorer**. For more information, see [Walkthrough: Creating a Dataset in the Dataset Designer](walkthrough-creating-a-dataset-with-the-dataset-designer.md).
7167

7268
2. Double-click the column you want to validate. This action creates the <xref:System.Data.DataTable.ColumnChanging> event handler.
7369

@@ -76,7 +72,7 @@ End Sub
7672
7773
3. Add code to verify that `e.ProposedValue` contains data that meets the requirements of your application. If the proposed value is unacceptable, set the column to indicate that it contains an error.
7874

79-
The following code example validates that the **Quantity** column contains more than 0. If **Quantity** is less than or equal to 0, the column is set to an error. The `Else` clause clears the error if **Quantity** is more than 0. The code in the column-changing event handler should resemble the following:
75+
The following code example validates that the **Quantity** column contains a value greater than 0. If **Quantity** is less than or equal to 0, the column is set to an error. The `Else` clause clears the error if **Quantity** is more than 0. The code in the column-changing event handler should resemble the following:
8076

8177
```vb
8278
If (e.Column.ColumnName = Me.QuantityColumn.ColumnName) Then
@@ -86,35 +82,32 @@ End Sub
8682
e.Row.SetColumnError(e.Column, "")
8783
End If
8884
End If
89-
```
90-
85+
```
9186
```csharp
92-
// C#
93-
// Add this code to the DataTable
94-
// partial class.
87+
// Add this code to the DataTable partial class.
9588

96-
public override void EndInit()
97-
{
98-
base.EndInit();
99-
// Hook up the ColumnChanging event
100-
// to call the SampleColumnChangingEvent method.
101-
ColumnChanging += SampleColumnChangingEvent;
102-
}
89+
public override void EndInit()
90+
{
91+
base.EndInit();
92+
// Hook up the ColumnChanging event
93+
// to call the SampleColumnChangingEvent method.
94+
ColumnChanging += SampleColumnChangingEvent;
95+
}
10396

104-
public void SampleColumnChangingEvent(object sender, System.Data.DataColumnChangeEventArgs e)
97+
public void SampleColumnChangingEvent(object sender, System.Data.DataColumnChangeEventArgs e)
98+
{
99+
if (e.Column.ColumnName == QuantityColumn.ColumnName)
105100
{
106-
if (e.Column.ColumnName == QuantityColumn.ColumnName)
101+
if ((short)e.ProposedValue <= 0)
102+
{
103+
e.Row.SetColumnError("Quantity", "Quantity must be greater than 0");
104+
}
105+
else
107106
{
108-
if ((short)e.ProposedValue <= 0)
109-
{
110-
e.Row.SetColumnError("Quantity", "Quantity must be greater than 0");
111-
}
112-
else
113-
{
114-
e.Row.SetColumnError("Quantity", "");
115-
}
107+
e.Row.SetColumnError("Quantity", "");
116108
}
117109
}
110+
}
118111
```
119112

120113
## Validate changes to whole rows
@@ -126,18 +119,18 @@ End Sub
126119

127120
#### To add validation during changes to whole rows
128121

129-
1. Open the dataset in The dataset by double-clicking the **.xsd** file in **Solution Explorer**. For more information, see [Walkthrough: Creating a Dataset in the Dataset Designer](walkthrough-creating-a-dataset-with-the-dataset-designer.md).
122+
1. Open the dataset by double-clicking the **.xsd** file in **Solution Explorer**. For more information, see [Walkthrough: Creating a Dataset in the Dataset Designer](walkthrough-creating-a-dataset-with-the-dataset-designer.md).
130123

131124
2. Double-click the title bar of the data table on the designer.
132125

133126
A partial class is created with a `RowChanging` event handler and opens in the Code Editor.
134127

135128
> [!NOTE]
136-
> The Dataset Designer does not automatically create an event handler for the <xref:System.Data.DataTable.RowChanging> event in C# projects. You have to create a method to handle the <xref:System.Data.DataTable.RowChanging> event and run code to hook up the event in the table's initialization method.
129+
> The Dataset Designer does not automatically create an event handler for the <xref:System.Data.DataTable.RowChanging> event in C# projects. You have to create a method to handle the <xref:System.Data.DataTable.RowChanging> event and run code then hook up the event in the table's initialization method.
137130

138131
3. Add user code inside the partial class declaration.
139132

140-
4. The following code shows where to add user code to validate during the <xref:System.Data.DataTable.RowChanging> event for Visual Basic:
133+
4. The following code shows where to add user code to validate data during the <xref:System.Data.DataTable.RowChanging> event:
141134

142135
```vb
143136
Partial Class OrdersDataTable
@@ -153,9 +146,6 @@ End Sub
153146
End Sub
154147
End Class
155148
```
156-
157-
5. The following code shows how to create the `RowChanging` event handler and where to add user code to validate during the <xref:System.Data.DataTable.RowChanging> event for C#:
158-
159149
```csharp
160150
partial class OrdersDataTable
161151
{

0 commit comments

Comments
 (0)