Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/framework/data/adonet/code-access-security.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ AllowBlankPassword="False">

You should see this output in the Console window:

```
```output
Failed, as expected: <IPermission class="System.Data.SqlClient.
SqlClientPermission, System.Data, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1"
Expand Down
2 changes: 1 addition & 1 deletion docs/framework/data/adonet/connection-string-builders.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Console.WriteLine(builder.ConnectionString);

The output shows that the <xref:System.Data.SqlClient.SqlConnectionStringBuilder> handled this correctly by escaping the extra value in double quotation marks instead of appending it to the connection string as a new key/value pair.

```
```output
data source=(local);Integrated Security=True;
initial catalog="AdventureWorks;NewValue=Bad"
```
Expand Down
32 changes: 16 additions & 16 deletions docs/framework/data/adonet/connection-string-syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ The syntax for a <xref:System.Data.SqlClient.SqlConnection> connection string is
### Windows authentication with SqlClient
Each of the following forms of syntax uses Windows Authentication to connect to the **AdventureWorks** database on a local server.

```
```csharp
"Persist Security Info=False;Integrated Security=true;
Initial Catalog=AdventureWorks;Server=MSSQL1"
"Persist Security Info=False;Integrated Security=SSPI;
Expand All @@ -60,7 +60,7 @@ The syntax for a <xref:System.Data.SqlClient.SqlConnection> connection string is
### SQL Server authentication with SqlClient
Windows Authentication is preferred for connecting to SQL Server. However, if SQL Server Authentication is required, use the following syntax to specify a user name and password. In this example, asterisks are used to represent a valid user name and password.

```
```csharp
"Persist Security Info=False;User ID=*****;Password=*****;Initial Catalog=AdventureWorks;Server=MySqlServer"
```

Expand All @@ -72,10 +72,10 @@ When you connect to Azure SQL Database or to Azure SQL Data Warehouse and provid
### Connect to a named instance of SQL Server
To connect to a named instance of SQL Server, use the *server name\instance name* syntax.

```csharp
"Data Source=MySqlServer\MSSQL1;"
```
Data Source=MySqlServer\MSSQL1;"
```


You can also set the <xref:System.Data.SqlClient.SqlConnectionStringBuilder.DataSource%2A> property of the `SqlConnectionStringBuilder` to the instance name when building a connection string. The <xref:System.Data.SqlClient.SqlConnection.DataSource%2A> property of a <xref:System.Data.SqlClient.SqlConnection> object is read-only.

### Type System Version Changes
Expand All @@ -89,8 +89,8 @@ You can also set the <xref:System.Data.SqlClient.SqlConnectionStringBuilder.Data
## Using TrustServerCertificate
The `TrustServerCertificate` keyword is valid only when connecting to a SQL Server instance with a valid certificate. When `TrustServerCertificate` is set to `true`, the transport layer will use SSL to encrypt the channel and bypass walking the certificate chain to validate trust.

```
"TrustServerCertificate=true;"
```csharp
"TrustServerCertificate=true;"
```

> [!NOTE]
Expand Down Expand Up @@ -121,13 +121,13 @@ You can also set the <xref:System.Data.SqlClient.SqlConnectionStringBuilder.Data
### OleDb Connection String Syntax
You must specify a provider name for an <xref:System.Data.OleDb.OleDbConnection> connection string. The following connection string connects to a Microsoft Access database using the Jet provider. Note that the `User ID` and `Password` keywords are optional if the database is unsecured (the default).

```
Provider=Microsoft.Jet.OLEDB.4.0; Data Source=d:\Northwind.mdb;User ID=Admin;Password=;
```csharp
Provider=Microsoft.Jet.OLEDB.4.0; Data Source=d:\Northwind.mdb;User ID=Admin;Password=;
```

If the Jet database is secured using user-level security, you must provide the location of the workgroup information file (.mdw). The workgroup information file is used to validate the credentials presented in the connection string.

```
```csharp
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\Northwind.mdb;Jet OLEDB:System Database=d:\NorthwindSystem.mdw;User ID=*****;Password=*****;
```

Expand All @@ -137,7 +137,7 @@ Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\Northwind.mdb;Jet OLEDB:System D
### Using DataDirectory to Connect to Access/Jet
`DataDirectory` is not exclusive to `SqlClient`. It can also be used with the <xref:System.Data.OleDb> and <xref:System.Data.Odbc> .NET data providers. The following sample <xref:System.Data.OleDb.OleDbConnection> string demonstrates the syntax required to connect to the Northwind.mdb located in the application's app_data folder. The system database (System.mdw) is also stored in that location.

```
```csharp
"Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=|DataDirectory|\Northwind.mdb;
Jet OLEDB:System Database=|DataDirectory|\System.mdw;"
Expand All @@ -149,7 +149,7 @@ Jet OLEDB:System Database=|DataDirectory|\System.mdw;"
### Connecting to Excel
The Microsoft Jet provider is used to connect to an Excel workbook. In the following connection string, the `Extended Properties` keyword sets properties that are specific to Excel. "HDR=Yes;" indicates that the first row contains column names, not data, and "IMEX=1;" tells the driver to always read "intermixed" data columns as text.

```
```csharp
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\MyExcel.xls;Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1""
```

Expand All @@ -158,7 +158,7 @@ Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\MyExcel.xls;Extended Properties=
### Data Shape Provider Connection String Syntax
Use both the `Provider` and the `Data Provider` keywords when using the Microsoft Data Shape provider. The following example uses the Shape provider to connect to a local instance of SQL Server.

```
```csharp
"Provider=MSDataShape;Data Provider=SQLOLEDB;Data Source=(local);Initial Catalog=pubs;Integrated Security=SSPI;"
```

Expand All @@ -167,22 +167,22 @@ Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\MyExcel.xls;Extended Properties=

The following connection string uses the Microsoft Text Driver.

```
```csharp
Driver={Microsoft Text Driver (*.txt; *.csv)};DBQ=d:\bin
```

### Using DataDirectory to Connect to Visual FoxPro
The following <xref:System.Data.Odbc.OdbcConnection> connection string sample demonstrates using `DataDirectory` to connect to a Microsoft Visual FoxPro file.

```
```csharp
"Driver={Microsoft Visual FoxPro Driver};
SourceDB=|DataDirectory|\MyData.DBC;SourceType=DBC;"
```

## Oracle Connection Strings
The <xref:System.Data.OracleClient.OracleConnection.ConnectionString%2A> property of a <xref:System.Data.OracleClient.OracleConnection> allows you to get or set a connection string for an OLE DB data source. Oracle connection strings are also supported by the <xref:System.Data.OracleClient.OracleConnectionStringBuilder> .

```
```csharp
Data Source=Oracle9i;User ID=*****;Password=*****;
```

Expand Down
10 changes: 5 additions & 5 deletions docs/framework/data/adonet/connection-strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,36 @@ A connection string contains initialization information that is passed as a para

A connection string is a semicolon-delimited list of key/value parameter pairs:

```
```csharp
keyword1=value; keyword2=value;
```

Keywords are not case-sensitive. Values, however, may be case-sensitive, depending on the data source. Both keywords and values may contain [whitespace characters](https://en.wikipedia.org/wiki/Whitespace_character#Unicode). Leading and trailing white space is ignored in keywords and unquoted values.

If a value contains the semicolon, [Unicode control characters](https://en.wikipedia.org/wiki/Unicode_control_characters), or leading or trailing white space, it must be enclosed in single or double quotation marks. For example:

```
```csharp
Keyword=" whitespace ";
Keyword='special;character';
```

The enclosing character may not occur within the value it encloses. Therefore, a value containing single quotation marks can be enclosed only in double quotation marks, and vice versa:

```
```csharp
Keyword='double"quotation;mark';
Keyword="single'quotation;mark";
```

You can also escape the enclosing character by using two of them together:

```
```csharp
Keyword="double""quotation";
Keyword='single''quotation';
```

The quotation marks themselves, as well as the equals sign, do not require escaping, so the following connection strings are valid:

```
```csharp
Keyword=no "escaping" 'required';
Keyword=a=b=c
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,25 @@ adapter.Fill(custDS, "Customers");
## Handling Multiple Result Sets
If your **SelectCommand** returns multiple tables, **Fill** automatically generates table names with incremental values for the tables in the **DataSet**, starting with the specified table name and continuing on in the form **TableName** *N*, starting with **TableName1**. You can use table mappings to map the automatically generated table name to a name you want specified for the table in the **DataSet**. For example, for a **SelectCommand** that returns two tables, **Customers** and **Orders**, issue the following call to **Fill**.

```
```vb
adapter.Fill(customersDataSet, "Customers")
```


```csharp
adapter.Fill(customersDataSet, "Customers");
```

Two tables are created in the **DataSet**: **Customers** and **Customers1**. You can use table mappings to ensure that the second table is named **Orders** instead of **Customers1**. To do this, map the source table of **Customers1** to the **DataSet** table **Orders**, as shown in the following example.

```
```vb
adapter.TableMappings.Add("Customers1", "Orders")
adapter.Fill(customersDataSet, "Customers")
```

```csharp
adapter.TableMappings.Add("Customers1", "Orders");
adapter.Fill(customersDataSet, "Customers");
```

## See also

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Annotations enable you to modify the names of the elements in your typed <xref:S

To use typed **DataSet** annotations, you must include the following **xmlns** reference in your XML Schema definition language (XSD) schema. To create an xsd from database tables, see <xref:System.Data.DataSet.WriteXmlSchema%2A> or [Working with Datasets in Visual Studio](/visualstudio/data-tools/dataset-tools-in-visual-studio).

```
```xml
xmlns:codegen="urn:schemas-microsoft-com:xml-msprop"
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The <xref:System.Data.DataTable> and <xref:System.Data.DataSet> classes have a <

The example displays the following output in the console window:

```
```output
1 Mary
2 Andy
3 Peter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ This section provides an overview of how the relational schema of a `DataSet` is

In the preceding example, the element `customers` is a complex type element. Therefore, the complex type definition is parsed, and the mapping process creates the following table.

```
Customers (CustomerID , CompanyName, Phone)
```text
Customers (CustomerID, CompanyName, Phone)
```

The data type of each column in the table is derived from the XML Schema type of the corresponding element or attribute specified.
Expand Down Expand Up @@ -71,9 +71,9 @@ Customers (CustomerID , CompanyName, Phone)

Both the `InStateCustomers` and the `OutOfStateCustomers` child elements are complex type elements (`customerType`). Therefore, the mapping process generates the following two identical tables in the `DataSet`.

```
InStateCustomers (CustomerID , CompanyName, Phone)
OutOfStateCustomers (CustomerID , CompanyName, Phone)
```text
InStateCustomers (CustomerID, CompanyName, Phone)
OutOfStateCustomers (CustomerID, CompanyName, Phone)
```

## In This Section
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ Given an XML Schema that complies with the XML Schema definition language (XSD)

The following code shows the syntax for generating a **DataSet** using this tool.

```
```console
xsd.exe /d /l:CS XSDSchemaFileName.xsd /eld /n:XSDSchema.Namespace
```

In this syntax, the `/d` directive tells the tool to generate a **DataSet**, and the `/l:` tells the tool what language to use (for example, C# or Visual Basic .NET). The optional `/eld` directive specifies that you can use LINQ to DataSet to query against the generated **DataSet.** This option is used when the `/d` option is also specified. For more information, see [Querying Typed DataSets](../querying-typed-datasets.md). The optional `/n:` directive tells the tool to also generate a namespace for the **DataSet** called **XSDSchema.Namespace**. The output of the command is XSDSchemaFileName.cs, which can be compiled and used in an ADO.NET application. The generated code can be compiled as a library or a module.

The following code shows the syntax for compiling the generated code as a library using the C# compiler (csc.exe).

```
```console
csc.exe /t:library XSDSchemaFileName.cs /r:System.dll /r:System.Data.dll
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ An XML Schema definition language (XSD) schema can have complex types nested ins

- An **Order** and an **OrderDetail** table.

```
```text
Order(OrderNumber, EmpNumber, Order_Id)
OrderDetail(OrderNo, ItemNo, Order_Id)
```

- A unique constraint on the **Order** table. Note that the **IsPrimaryKey** property is set to **True**.

```
```text
ConstraintName: Constraint1
Type: UniqueConstraint
Table: Order
Expand All @@ -69,7 +69,7 @@ An XML Schema definition language (XSD) schema can have complex types nested ins

- A foreign key constraint on the **OrderDetail** table.

```
```text
ConstraintName: Order_OrderDetail
Type: ForeignKeyConstraint
Table: OrderDetail
Expand All @@ -80,7 +80,7 @@ An XML Schema definition language (XSD) schema can have complex types nested ins

- A relationship between the **Order** and **OrderDetail** tables. The **Nested** property for this relationship is set to **True** because the **Order** and **OrderDetail** elements are nested in the schema.

```
```text
ParentTable: Order
ParentColumns: Order_Id
ChildTable: OrderDetail
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ In a schema, you can specify a key constraint on an element or attribute using t

The **key** element specifies that the values of the **CustomerID** child element of the **Customers** element must have unique values and cannot have null values. In translating the XML Schema definition language (XSD) schema, the mapping process creates the following table:

```
```text
Customers(CustomerID, CompanyName, Phone)
```

The XML Schema mapping also creates a **UniqueConstraint** on the **CustomerID** column, as shown in the following <xref:System.Data.DataSet>. (For simplicity, only relevant properties are shown.)

```
```text
DataSetName: MyDataSet
TableName: customers
ColumnName: CustomerID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ The **keyref** element allows you to establish links between elements within a d

The XML Schema definition language (XSD) schema mapping process produces the following **DataSet** with two tables:

```
```text
OrderDetail(OrderNo, ItemNo) and
Order(OrderNumber, EmpNumber)
```
Expand All @@ -71,17 +71,17 @@ Order(OrderNumber, EmpNumber)

- A unique constraint on the **Order** table.

```
```text
Table: Order
Columns: OrderNumber
Columns: OrderNumber
ConstraintName: OrderNumberKey
Type: UniqueConstraint
IsPrimaryKey: False
```

- A relationship between the **Order** and **OrderDetail** tables. The **Nested** property is set to **False** because the two elements are not nested in the schema.

```
```text
ParentTable: Order
ParentColumns: OrderNumber
ChildTable: OrderDetail
Expand All @@ -94,13 +94,13 @@ Order(OrderNumber, EmpNumber)

- A foreign key constraint on the **OrderDetail** table.

```
```text
ConstraintName: OrderNoRef
Type: ForeignKeyConstraint
Table: OrderDetail
Columns: OrderNo
Columns: OrderNo
RelatedTable: Order
RelatedColumns: OrderNumber
RelatedColumns: OrderNumber
```

## See also
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ A schema can include an **msdata:Relationship** annotation to explicitly specify

- An **Order** and an **OrderDetail** table.

```
```text
Order(OrderNumber, EmpNumber)
OrderDetail(OrderNo, ItemNo)
```

- A relationship between the **Order** and **OrderDetail** tables. The **Nested** property for this relationship is set to **True** because the **Order** and **OrderDetail** elements are nested in the schema.

```
```text
ParentTable: Order
ParentColumns: OrderNumber
ChildTable: OrderDetail
Expand Down
Loading