13694 lines
1.1 MiB
XML
13694 lines
1.1 MiB
XML
|
<?xml version="1.0"?>
|
||
|
<doc>
|
||
|
<assembly>
|
||
|
<name>Microsoft.Data.SqlClient</name>
|
||
|
</assembly>
|
||
|
<members>
|
||
|
<member name="T:Microsoft.Data.OperationAbortedException">
|
||
|
<summary>This exception is thrown when an ongoing operation is aborted by the user.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This exception indicates that an operation has been aborted by the consumer of an API.
|
||
|
For example, if the event handler of the <xref:Microsoft.Data.SqlClient.SqlBulkCopy.SqlRowsCopied> event sets the **Abort** property to `true` in the <xref:Microsoft.Data.SqlClient.SqlRowsCopiedEventArgs> object passed to the handler, the <xref:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer%2A> method stops sending rows to the server and throws an <xref:Microsoft.Data.OperationAbortedException>.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.Sql.SqlNotificationRequest">
|
||
|
<summary>Represents a request for notification for a given command.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This class provides low-level access to the query notification services exposed by SQL Server 2005. For most applications the <xref:Microsoft.Data.SqlClient.SqlDependency> class provides a simpler way of using query notifications. However, if you need fine control over when notifications occur, or you need to customize the message data returned as part of a notification, the <xref:Microsoft.Data.Sql.SqlNotificationRequest> class is the one to use.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><related type="Article" href="/sql/connect/ado-net/sql/query-notifications-sql-server">Using Query Notifications</related>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.Sql.SqlNotificationRequest.#ctor">
|
||
|
<summary>Creates a new instance of the <see cref="T:Microsoft.Data.Sql.SqlNotificationRequest" /> class with default values.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
If the parameterless constructor is used to create a <xref:Microsoft.Data.Sql.SqlNotificationRequest> object, that instance must have its <xref:Microsoft.Data.Sql.SqlNotificationRequest.UserData%2A> and <xref:Microsoft.Data.Sql.SqlNotificationRequest.Options%2A> properties initialized before assigning the object to a <xref:Microsoft.Data.SqlClient.SqlCommand> object's <xref:Microsoft.Data.SqlClient.SqlCommand.Notification%2A> property. The default values used by the constructor are NULL (`Nothing` in Visual Basic) for the <xref:Microsoft.Data.Sql.SqlNotificationRequest.UserData%2A>, an empty string for the <xref:Microsoft.Data.Sql.SqlNotificationRequest.Options%2A>, and zero for the <xref:Microsoft.Data.Sql.SqlNotificationRequest.Timeout%2A>.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><related type="Article" href="/sql/connect/ado-net/sql/query-notifications-sql-server">Using Query Notifications</related>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.Sql.SqlNotificationRequest.#ctor(System.String,System.String,System.Int32)">
|
||
|
<param name="userData">A string that contains an application-specific identifier for this notification. It is not used by the notifications infrastructure, but it allows you to associate notifications with the application state. The value indicated in this parameter is included in the Service Broker queue message.</param><param name="options">A string that contains the Service Broker service name where notification messages are posted, and it must include a database name or a Service Broker instance GUID that restricts the scope of the service name lookup to a particular database. For more information about the format of the <paramref name="options" /> parameter, see <see cref="P:Microsoft.Data.Sql.SqlNotificationRequest.Options" />.</param><param name="timeout">The time, in seconds, to wait for a notification message.</param><summary>Creates a new instance of the <see cref="T:Microsoft.Data.Sql.SqlNotificationRequest" /> class with a user-defined string that identifies a particular notification request, the name of a predefined SQL Server 2005 Service Broker service name, and the time-out period, measured in seconds.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This constructor allows you to initialize a new <xref:Microsoft.Data.Sql.SqlNotificationRequest> instance, providing your own identifier, the SQL Server 2005 Service Broker service name, and a time-out value.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">The value of the <paramref name="options" /> parameter is NULL.</exception><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="options" /> or <paramref name="userData" /> parameter is longer than <see langword="uint16.MaxValue" /> or the value in the <paramref name="timeout" /> parameter is less than zero.</exception><related type="Article" href="/sql/connect/ado-net/sql/query-notifications-sql-server">Using Query Notifications</related>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.Sql.SqlNotificationRequest.Options">
|
||
|
<summary>Gets or sets the SQL Server Service Broker service name where notification messages are posted.</summary><value>
|
||
|
<see langword="string" /> that contains the SQL Server 2005 Service Broker service name where notification messages are posted and the database or service broker instance GUID to scope the server name lookup.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The value of the <xref:Microsoft.Data.Sql.SqlNotificationRequest.Options%2A> property has the following format:
|
||
|
|
||
|
`service=<service-name>{;(local database=<database>|broker instance=<broker instance>)}`
|
||
|
|
||
|
For example, if you use the service "myservice" in the database "AdventureWorks" the format is:
|
||
|
|
||
|
`service=myservice;local database=AdventureWorks`
|
||
|
|
||
|
The SQL Server Service Broker service must be previously configured on the server. In addition, a Service Broker service and queue must be defined and security access granted as needed. See the SQL Server 2005 documentation for more information.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">The value is NULL.</exception><exception cref="T:System.ArgumentException">The value is longer than <see langword="uint16.MaxValue" />.</exception><related type="Article" href="/sql/connect/ado-net/sql/query-notifications-sql-server">Using Query Notifications</related>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.Sql.SqlNotificationRequest.Timeout">
|
||
|
<summary>Gets or sets a value that specifies how long SQL Server waits for a change to occur before the operation times out.</summary><value>A signed integer value that specifies, in seconds, how long SQL Server waits for a change to occur before the operation times out.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
After the time-out period expires, the notification is sent even if no change takes place. The <xref:Microsoft.Data.Sql.SqlNotificationRequest.Timeout%2A> property defaults to the value set on the server.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentOutOfRangeException">The value is less than zero.</exception><related type="Article" href="/sql/connect/ado-net/sql/query-notifications-sql-server">Using Query Notifications</related>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.Sql.SqlNotificationRequest.UserData">
|
||
|
<summary>Gets or sets an application-specific identifier for this notification.</summary><value>A <see langword="string" /> value of the application-specific identifier for this notification.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This value is not used by the notifications infrastructure. Instead, it is a mechanism that allows an application to associate notifications with application state. The value specified in the <xref:Microsoft.Data.Sql.SqlNotificationRequest.UserData%2A> property is included in the SQL Server 2005 queue message.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentException">The value is longer than <see langword="uint16.MaxValue" />.</exception><related type="Article" href="/sql/connect/ado-net/sql/query-notifications-sql-server">Using Query Notifications</related>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.Sql.SqlDataSourceEnumerator">
|
||
|
<summary>Provides a mechanism for enumerating all available instances of SQL Server within the local network.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
SQL Server makes it possible for applications to determine the existence of its instances within the current network. The <xref:Microsoft.Data.Sql.SqlDataSourceEnumerator> class exposes this information to the application developer, providing a <xref:System.Data.DataTable> containing information about all the available servers. This returned table contains a list of server instances that matches the list provided when a user attempts to create a new connection, and on the `Connection Properties` dialog box, expands the drop-down list containing all the available servers.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><related type="Article" href="/dotnet/framework/data/adonet/sql/enumerating-instances-of-sql-server">Enumerating Instances of SQL Server</related>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.Sql.SqlDataSourceEnumerator.Instance">
|
||
|
<summary>Gets an instance of the <see cref="T:Microsoft.Data.Sql.SqlDataSourceEnumerator" />, which can be used to retrieve information about available SQL Server instances.</summary><value>An instance of the <see cref="T:Microsoft.Data.Sql.SqlDataSourceEnumerator" /> used to retrieve information about available SQL Server instances.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.Sql.SqlDataSourceEnumerator> class does not provide a constructor. Use the <xref:Microsoft.Data.Sql.SqlDataSourceEnumerator.Instance%2A> property to retrieve an instance of the class instead.
|
||
|
|
||
|
[!code-csharp[SqlDataSourceEnumeratorExample#1](~/../sqlclient/doc/samples/SqlDataSourceEnumeratorExample.cs#1)]
|
||
|
|
||
|
## Examples
|
||
|
The following console application displays a list of all the available SQL Server 2005 instances within the local network. This code uses the <xref:System.Data.DataTable.Select%2A> method to filter the rows in the table returned by the <xref:Microsoft.Data.Sql.SqlDataSourceEnumerator.GetDataSources%2A> method.
|
||
|
[!code-csharp[SqlDataSourceEnumeratorVersionExample#1](~/../sqlclient/doc/samples/SqlDataSourceEnumeratorVersionExample.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><related type="Article" href="/dotnet/framework/data/adonet/sql/enumerating-instances-of-sql-server">Enumerating Instances of SQL Server</related>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.Sql.SqlDataSourceEnumerator.GetDataSources">
|
||
|
<summary>Retrieves a <see cref="T:System.Data.DataTable" /> containing information about all visible SQL Server instances.</summary><returns>A <see cref="T:System.Data.DataTable" /> containing information about the visible SQL Server instances.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The table returned by this method contains the following columns, all of which contain strings:
|
||
|
|
||
|
|Column|Description|
|
||
|
|------------|-----------------|
|
||
|
|**ServerName**|Name of the server.|
|
||
|
|**InstanceName**|Name of the server instance. Blank if the server is running as the default instance.|
|
||
|
|**IsClustered**|Indicates whether the server is part of a cluster.|
|
||
|
|**Version**|Version of the server:<br /><br />10.0.xx for SQL Server 2008<br />10.50.x for SQL Server 2008 R2<br />11.0.xx for SQL Server 2012<br />12.0.xx for SQL Server 2014<br />13.0.xx for SQL Server 2016<br />14.0.xx for SQL Server 2017|
|
||
|
|
||
|
> [!NOTE]
|
||
|
> Due to the nature of the mechanism used by <xref:Microsoft.Data.Sql.SqlDataSourceEnumerator> to locate data sources on a network, the method will not always return a complete list of the available servers, and the list might not be the same on every call. If you plan to use this function to let users select a server from a list, make sure that you always also supply an option to type in a name that is not in the list, in case the server enumeration does not return all the available servers. In addition, this method may take a significant amount of time to execute, so be careful about calling it when performance is critical.
|
||
|
|
||
|
## Examples
|
||
|
The following console application retrieves information about all the visible SQL Server instances and displays the information in the console window.
|
||
|
|
||
|
[!code-csharp[SqlDataSourceEnumerator.Example#1](~/../sqlclient/doc/samples/SqlDataSourceEnumeratorExample.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><related type="Article" href="/dotnet/framework/data/adonet/sql/enumerating-instances-of-sql-server">Enumerating Instances of SQL Server</related>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlTypes.SqlFileStream">
|
||
|
<summary>Exposes SQL Server data that is stored with the FILESTREAM column attribute as a sequence of bytes.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlTypes.SqlFileStream> class is used to work with `varbinary(max)` data stored with the FILESTREAM attribute in a SQL Server 2008 database. You must install the .NET Framework 3.5 SP1 (or later) to use <xref:Microsoft.Data.SqlTypes.SqlFileStream> to work with FILESTREAM data.
|
||
|
|
||
|
Specifying the FILESTREAM attribute on a `varbinary(max)` column causes SQL Server to store the data in the local NTFS file system instead of in the database file. Transact-SQL statements provide data manipulation capabilities within the server, and Win32 file system interfaces provide streaming access to the data.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> Individual files stored in a FILESTREAM column cannot be opened directly from the NTFS file system. Streaming FILESTREAM data works only in the context of a SQL Server transaction.
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlTypes.SqlFileStream> class is derived from the <xref:System.IO.Stream> class, which represents an abstraction of a sequence of bytes from some arbitrary data source such as a file or a block of memory. You can read from a FILESTREAM by transferring data from a stream into a data structure such as an array of bytes. You can write to a FILESTREAM by transferring the data from a data structure into a stream. You can also seek within the stream, which allows you to query and modify data at the current position within the stream.
|
||
|
|
||
|
For conceptual documentation and code examples, see [FILESTREAM Data](/sql/connect/ado-net/sql/filestream-data).
|
||
|
|
||
|
For documentation about setting up and configuring FILESTREAM data on SQL Server, see [Designing and Implementing FILESTREAM Storage](https://go.microsoft.com/fwlink/?LinkId=121499) in SQL Server 2008 Books Online.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><related type="Article" href="https://msdn.microsoft.com/library/bd8b845c-0f09-4295-b466-97ef106eefa8">FILESTREAM Data in SQL Server 2008 (ADO.NET)</related><related type="Article" href="https://msdn.microsoft.com/library/fafdc31a-f435-4cd3-883f-1dfadd971277">SQL Server Data Type Mappings (ADO.NET)</related><related type="Article" href="https://msdn.microsoft.com/library/e00827b3-7511-4b2d-91d7-851ca86cc6b5">SQL Server Binary and Large-Value Data (ADO.NET)</related>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlTypes.SqlFileStream.#ctor(System.String,System.Byte[],System.IO.FileAccess)">
|
||
|
<param name="path">The logical path to the file. The path can be retrieved by using the Transact-SQL Pathname function on the underlying FILESTREAM column in the table.</param><param name="transactionContext">The transaction context for the <see langword="SqlFileStream" /> object. Applications should return the byte array returned by calling the GET_FILESTREAM_TRANSACTION_CONTEXT method.</param><param name="access">The access mode to use when opening the file. Supported <see cref="T:System.IO.FileAccess" /> enumeration values are <see cref="F:System.IO.FileAccess.Read" />, <see cref="F:System.IO.FileAccess.Write" />, and <see cref="F:System.IO.FileAccess.ReadWrite" />.
|
||
|
|
||
|
When using <see langword="FileAccess.Read" />, the <see langword="SqlFileStream" /> object can be used to read all of the existing data.
|
||
|
|
||
|
When using <see langword="FileAccess.Write" />, <see langword="SqlFileStream" /> points to a zero byte file. Existing data will be overwritten when the object is closed and the transaction is committed.
|
||
|
|
||
|
When using <see langword="FileAccess.ReadWrite" />, the <see langword="SqlFileStream" /> points to a file which has all the existing data in it. The handle is positioned at the beginning of the file. You can use one of the <see langword="System.IO" /><see langword="Seek" /> methods to move the handle position within the file to write or append new data.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlTypes.SqlFileStream" /> class.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The following table lists the code access security (CAS) permissions that all callers in the stack must have to use the `SqlFileStream` constructors.
|
||
|
|
||
|
|File access|Permission|
|
||
|
|-----------------|----------------|
|
||
|
|Read|<xref:System.Security.Permissions.FileIOPermissionAccess.Read>|
|
||
|
|Write|<xref:System.Security.Permissions.FileIOPermissionAccess.Write>|
|
||
|
|ReadWrite|<xref:System.Security.Permissions.FileIOPermissionAccess.Read> and <xref:System.Security.Permissions.FileIOPermissionAccess.Write>|
|
||
|
|
||
|
For more information about CAS, see [Code Access Security and ADO.NET](/dotnet/framework/data/adonet/code-access-security).
|
||
|
|
||
|
If an exception is thrown, any open transactions should be rolled back. Otherwise, data loss can occur.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">
|
||
|
<paramref name="path" /> is a null reference, or <paramref name="transactionContext" /> is null.</exception><exception cref="T:System.ArgumentOutOfRangeException">
|
||
|
<paramref name="path" /> is an empty string (""), contains only white space, or contains one or more invalid characters.
|
||
|
<paramref name="path" /> begins with "\\\\.\\", for example "\\\\.\PHYSICALDRIVE0 ".
|
||
|
The handle returned by the call to NTCreateFile is not of type FILE_TYPE_DISK.
|
||
|
<paramref name="path" /> contains an unsupported value.</exception><exception cref="T:System.IO.FileNotFoundException">The file cannot be found.</exception><exception cref="T:System.IO.IOException">An I/O error occurred.</exception><exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception><exception cref="T:System.IO.DirectoryNotFoundException">The specified <paramref name="path" /> is invalid, such as being on an unmapped drive.</exception><exception cref="T:System.UnauthorizedAccessException">The access requested is not permitted by the operating system for the specified path. This occurs when Write or ReadWrite access is specified, and the file or directory is set for read-only access.</exception><exception cref="T:System.InvalidOperationException">NtCreateFile fails with error code set to ERROR_SHARING_VIOLATION.</exception><related type="Article" href="https://msdn.microsoft.com/library/bd8b845c-0f09-4295-b466-97ef106eefa8">FILESTREAM Data in SQL Server 2008 (ADO.NET)</related>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlTypes.SqlFileStream.#ctor(System.String,System.Byte[],System.IO.FileAccess,System.IO.FileOptions,System.Int64)">
|
||
|
<param name="path">The logical path to the file. The path can be retrieved by using the Transact-SQL Pathname function on the underlying FILESTREAM column in the table.</param><param name="transactionContext">The transaction context for the <see langword="SqlFileStream" /> object. When set to null, an implicit transaction will be used for the <see langword="SqlFileStream" /> object. Applications should return the byte array returned by calling the GET_FILESTREAM_TRANSACTION_CONTEXT method.</param><param name="access">The access mode to use when opening the file. Supported <see cref="T:System.IO.FileAccess" /> enumeration values are <see cref="F:System.IO.FileAccess.Read" />, <see cref="F:System.IO.FileAccess.Write" />, and <see cref="F:System.IO.FileAccess.ReadWrite" />.
|
||
|
|
||
|
When using <see langword="FileAccess.Read" />, the <see langword="SqlFileStream" /> object can be used to read all of the existing data.
|
||
|
|
||
|
When using <see langword="FileAccess.Write" />, <see langword="SqlFileStream" /> points to a zero byte file. Existing data will be overwritten when the object is closed and the transaction is committed.
|
||
|
|
||
|
When using <see langword="FileAccess.ReadWrite" />, the <see langword="SqlFileStream" /> points to a file which has all the existing data in it. The handle is positioned at the beginning of the file. You can use one of the <see langword="System.IO" /><see langword="Seek" /> methods to move the handle position within the file to write or append new data.</param><param name="options">Specifies the option to use while opening the file. Supported <see cref="T:System.IO.FileOptions" /> values are <see cref="F:System.IO.FileOptions.Asynchronous" />, <see cref="F:System.IO.FileOptions.WriteThrough" />, <see cref="F:System.IO.FileOptions.SequentialScan" />, and <see cref="F:System.IO.FileOptions.RandomAccess" />.</param><param name="allocationSize">The allocation size to use while creating a file. If set to 0, the default value is used.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlTypes.SqlFileStream" /> class.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The following table lists the code access security (CAS) permissions that all callers in the stack must have to use the `SqlFileStream` constructors.
|
||
|
|
||
|
|File access|Permission|
|
||
|
|-----------------|----------------|
|
||
|
|Read|<xref:System.Security.Permissions.FileIOPermissionAccess.Read>|
|
||
|
|Write|<xref:System.Security.Permissions.FileIOPermissionAccess.Write>|
|
||
|
|ReadWrite|<xref:System.Security.Permissions.FileIOPermissionAccess.Read> and <xref:System.Security.Permissions.FileIOPermissionAccess.Write>|
|
||
|
|
||
|
For more information about CAS, see [Code Access Security and ADO.NET](/dotnet/framework/data/adonet/code-access-security).
|
||
|
|
||
|
If an exception is thrown, any open transactions should be rolled back. Otherwise, data loss can occur.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">
|
||
|
<paramref name="path" /> is a null reference, or <paramref name="transactionContext" /> is null.</exception><exception cref="T:System.ArgumentOutOfRangeException">
|
||
|
<paramref name="path" /> is an empty string (""), contains only white space, or contains one or more invalid characters.
|
||
|
|
||
|
<paramref name="path" /> begins with "\\\\.\\", for example "\\\\.\PHYSICALDRIVE0 "
|
||
|
|
||
|
The handle returned by call to NTCreateFile is not of type FILE_TYPE_DISK.
|
||
|
|
||
|
<paramref name="options" /> contains an unsupported value.</exception><exception cref="T:System.IO.FileNotFoundException">The file cannot be found.</exception><exception cref="T:System.IO.IOException">An I/O error occurred.</exception><exception cref="T:System.Security.SecurityException">The caller does not have the required permission.</exception><exception cref="T:System.IO.DirectoryNotFoundException">The specified <paramref name="path" /> is invalid, such as being on an unmapped drive.</exception><exception cref="T:System.UnauthorizedAccessException">The access requested is not permitted by the operating system for the specified path. This occurs when Write or ReadWrite access is specified, and the file or directory is set for read-only access.</exception><exception cref="T:System.InvalidOperationException">NtCreateFile fails with error code set to ERROR_SHARING_VIOLATION.</exception><related type="Article" href="https://msdn.microsoft.com/library/bd8b845c-0f09-4295-b466-97ef106eefa8">FILESTREAM Data in SQL Server 2008 (ADO.NET)</related>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlTypes.SqlFileStream.Name">
|
||
|
<summary>Gets the logical path of the <see cref="T:Microsoft.Data.SqlTypes.SqlFileStream" /> passed to the constructor.</summary><value>A string value indicating the name of the <see cref="T:Microsoft.Data.SqlTypes.SqlFileStream" />.</value><remarks>To be added.</remarks><related type="Article" href="https://msdn.microsoft.com/library/bd8b845c-0f09-4295-b466-97ef106eefa8">FILESTREAM Data in SQL Server 2008 (ADO.NET)</related>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlTypes.SqlFileStream.TransactionContext">
|
||
|
<summary>Gets or sets the transaction context for this <see cref="T:Microsoft.Data.SqlTypes.SqlFileStream" /> object.</summary><value>The <see cref="T:Microsoft.Data.SqlTypes.SqlFileStream.TransactionContext" /> array that was passed to the constructor for this <see cref="T:Microsoft.Data.SqlTypes.SqlFileStream" /> object.</value><remarks>To be added.</remarks><related type="Article" href="https://msdn.microsoft.com/library/bd8b845c-0f09-4295-b466-97ef106eefa8">FILESTREAM Data in SQL Server 2008 (ADO.NET)</related>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlTypes.SqlFileStream.CanRead">
|
||
|
<summary>Gets a value indicating whether the current stream supports reading.</summary><value>
|
||
|
<see langword="true" /> if the current stream supports reading; otherwise, <see langword="false" />.</value><remarks>To be added.</remarks><related type="Article" href="https://msdn.microsoft.com/library/bd8b845c-0f09-4295-b466-97ef106eefa8">FILESTREAM Data in SQL Server 2008 (ADO.NET)</related>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlTypes.SqlFileStream.CanSeek">
|
||
|
<summary>Gets a value indicating whether the current stream supports seeking.</summary><value>
|
||
|
<see langword="true" /> if the current stream supports seeking; otherwise, <see langword="false" />.</value><remarks>To be added.</remarks><related type="Article" href="https://msdn.microsoft.com/library/bd8b845c-0f09-4295-b466-97ef106eefa8">FILESTREAM Data in SQL Server 2008 (ADO.NET)</related>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlTypes.SqlFileStream.CanTimeout">
|
||
|
<summary>Gets a value indicating whether the current stream can time out.</summary><value>
|
||
|
<see langword="true" /> if the current stream can time out; otherwise, <see langword="false" />.</value><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlTypes.SqlFileStream.CanWrite">
|
||
|
<summary>Gets a value indicating whether the current stream supports writing.</summary><value>
|
||
|
<see langword="true" /> if the current stream supports writing; otherwise, <see langword="false" />.</value><remarks>To be added.</remarks><related type="Article" href="https://msdn.microsoft.com/library/bd8b845c-0f09-4295-b466-97ef106eefa8">FILESTREAM Data in SQL Server 2008 (ADO.NET)</related>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlTypes.SqlFileStream.Length">
|
||
|
<summary>Gets a value indicating the length of the current stream in bytes.</summary><value>An <see cref="T:System.Int64" /> indicating the length of the current stream in bytes.</value><remarks>To be added.</remarks><related type="Article" href="https://msdn.microsoft.com/library/bd8b845c-0f09-4295-b466-97ef106eefa8">FILESTREAM Data in SQL Server 2008 (ADO.NET)</related>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlTypes.SqlFileStream.Position">
|
||
|
<summary>Gets or sets the position within the current stream.</summary><value>The current position within the <see cref="T:Microsoft.Data.SqlTypes.SqlFileStream" />.</value><remarks>To be added.</remarks><related type="Article" href="https://msdn.microsoft.com/library/bd8b845c-0f09-4295-b466-97ef106eefa8">FILESTREAM Data in SQL Server 2008 (ADO.NET)</related>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlTypes.SqlFileStream.ReadTimeout">
|
||
|
<summary>Gets or sets a value, in milliseconds, that determines how long the stream will attempt to read before timing out.</summary><value>A value, in milliseconds, that determines how long the stream will attempt to read before timing out.</value><remarks>To be added.</remarks><related type="Article" href="https://msdn.microsoft.com/library/bd8b845c-0f09-4295-b466-97ef106eefa8">FILESTREAM Data in SQL Server 2008 (ADO.NET)</related>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlTypes.SqlFileStream.WriteTimeout">
|
||
|
<summary>Gets or sets a value, in milliseconds, that determines how long the stream will attempt to write before timing out.</summary><value>A value, in milliseconds, that determines how long the stream will attempt to write before timing out.</value><remarks>To be added.</remarks><related type="Article" href="https://msdn.microsoft.com/library/bd8b845c-0f09-4295-b466-97ef106eefa8">FILESTREAM Data in SQL Server 2008 (ADO.NET)</related>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlTypes.SqlFileStream.Flush">
|
||
|
<summary>Clears all buffers for this stream and causes any buffered data to be written to the underlying device.</summary><remarks>To be added.</remarks><related type="Article" href="https://msdn.microsoft.com/library/bd8b845c-0f09-4295-b466-97ef106eefa8">FILESTREAM Data in SQL Server 2008 (ADO.NET)</related>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlTypes.SqlFileStream.BeginRead(System.Byte[],System.Int32,System.Int32,System.AsyncCallback,System.Object)">
|
||
|
<param name="buffer">The buffer to read the data into.</param><param name="offset">The byte offset in <paramref name="buffer" /> at which to begin writing data read from the stream.</param><param name="count">The maximum number of bytes to read.</param><param name="callback">An optional asynchronous callback, to be called when the read is complete.</param><param name="state">A user-provided object that distinguishes this particular asynchronous read request from other requests</param><summary>Begins an asynchronous read operation.</summary><returns>An <see cref="T:System.IAsyncResult" /> that represents the asynchronous read, which could still be pending.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Use the <xref:Microsoft.Data.SqlTypes.SqlFileStream.CanRead%2A> property to determine whether the current instance supports reading.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.NotSupportedException">Reading data is not supported on the stream.</exception><related type="Article" href="https://msdn.microsoft.com/library/bd8b845c-0f09-4295-b466-97ef106eefa8">FILESTREAM Data in SQL Server 2008 (ADO.NET)</related>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlTypes.SqlFileStream.EndRead(System.IAsyncResult)">
|
||
|
<param name="asyncResult">The reference to the pending asynchronous request to finish.</param><summary>Waits for the pending asynchronous read to complete.</summary><returns>The number of bytes read from the stream, between zero (0) and the number of bytes you requested. Streams return zero (0) only at the end of the stream, otherwise, they should block until at least one byte is available.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">The <see cref="T:System.IAsyncResult" /> object did not come from the corresponding <see langword="BeginRead" /> method.</exception><related type="Article" href="https://msdn.microsoft.com/library/bd8b845c-0f09-4295-b466-97ef106eefa8">FILESTREAM Data in SQL Server 2008 (ADO.NET)</related>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlTypes.SqlFileStream.BeginWrite(System.Byte[],System.Int32,System.Int32,System.AsyncCallback,System.Object)">
|
||
|
<param name="buffer">The buffer to write data from.</param><param name="offset">The byte offset in <paramref name="buffer" /> from which to begin writing.</param><param name="count">The maximum number of bytes to write.</param><param name="callback">An optional asynchronous callback, to be called when the write is complete.</param><param name="state">A user-provided object that distinguishes this particular asynchronous write request from other requests.</param><summary>Begins an asynchronous write operation.</summary><returns>An <see cref="T:System.IAsyncResult" /> that represents the asynchronous write, which could still be pending.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Use the <xref:Microsoft.Data.SqlTypes.SqlFileStream.CanWrite%2A> property to determine whether the current instance supports writing.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.NotSupportedException">Writing data is not supported on the stream.</exception><related type="Article" href="https://msdn.microsoft.com/library/bd8b845c-0f09-4295-b466-97ef106eefa8">FILESTREAM Data in SQL Server 2008 (ADO.NET)</related>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlTypes.SqlFileStream.EndWrite(System.IAsyncResult)">
|
||
|
<param name="asyncResult">A reference to the outstanding asynchronous I/O request.</param><summary>Ends an asynchronous write operation.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">The <see cref="T:System.IAsyncResult" /> object did not come from the corresponding <see langword="BeginWrite" /> method.</exception><related type="Article" href="https://msdn.microsoft.com/library/bd8b845c-0f09-4295-b466-97ef106eefa8">FILESTREAM Data in SQL Server 2008 (ADO.NET)</related>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlTypes.SqlFileStream.Seek(System.Int64,System.IO.SeekOrigin)">
|
||
|
<param name="offset">A byte offset relative to the <paramref name="origin" /> parameter</param><param name="origin">A value of type <see cref="T:System.IO.SeekOrigin" /> indicating the reference point used to obtain the new position</param><summary>Sets the position within the current stream.</summary><returns>The new position within the current stream.</returns><remarks>To be added.</remarks><related type="Article" href="https://msdn.microsoft.com/library/bd8b845c-0f09-4295-b466-97ef106eefa8">FILESTREAM Data in SQL Server 2008 (ADO.NET)</related>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlTypes.SqlFileStream.SetLength(System.Int64)">
|
||
|
<param name="value">The desired length of the current stream in bytes.</param><summary>Sets the length of the current stream.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Use the <xref:Microsoft.Data.SqlTypes.SqlFileStream.CanRead%2A> property to determine whether the current instance supports reading.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.NotSupportedException">The object does not support reading of data.</exception><related type="Article" href="https://msdn.microsoft.com/library/bd8b845c-0f09-4295-b466-97ef106eefa8">FILESTREAM Data in SQL Server 2008 (ADO.NET)</related>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlTypes.SqlFileStream.Read(System.Byte[],System.Int32,System.Int32)">
|
||
|
<param name="buffer">An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source.</param><param name="offset">The zero-based byte offset in buffer at which to begin storing the data read from the current stream.</param><param name="count">The maximum number of bytes to be read from the current stream.</param><summary>Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.</summary><returns>The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if the end of the stream has been reached.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Use the <xref:Microsoft.Data.SqlTypes.SqlFileStream.CanRead%2A> property to determine whether the current instance supports writing.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.NotSupportedException">The object does not support reading of data.</exception><related type="Article" href="https://msdn.microsoft.com/library/bd8b845c-0f09-4295-b466-97ef106eefa8">FILESTREAM Data in SQL Server 2008 (ADO.NET)</related>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlTypes.SqlFileStream.ReadByte">
|
||
|
<summary>Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.</summary><returns>The unsigned byte cast to an <see cref="T:System.Int32" />, or -1 if at the end of the stream.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Use the <xref:Microsoft.Data.SqlTypes.SqlFileStream.CanRead%2A> property to determine whether the current instance supports reading.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.NotSupportedException">The object does not support reading of data.</exception><related type="Article" href="https://msdn.microsoft.com/library/bd8b845c-0f09-4295-b466-97ef106eefa8">FILESTREAM Data in SQL Server 2008 (ADO.NET)</related>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlTypes.SqlFileStream.Write(System.Byte[],System.Int32,System.Int32)">
|
||
|
<param name="buffer">An array of bytes. This method copies <paramref name="count" /> bytes from <paramref name="buffer" /> to the current stream.</param><param name="offset">The zero-based byte offset in <paramref name="buffer" /> at which to begin copying bytes to the current stream.</param><param name="count">The number of bytes to be written to the current stream.</param><summary>Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Use the <xref:Microsoft.Data.SqlTypes.SqlFileStream.CanWrite%2A> property to determine whether the current instance supports writing.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.NotSupportedException">The object does not support writing of data.</exception><related type="Article" href="https://msdn.microsoft.com/library/bd8b845c-0f09-4295-b466-97ef106eefa8">FILESTREAM Data in SQL Server 2008 (ADO.NET)</related>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlTypes.SqlFileStream.WriteByte(System.Byte)">
|
||
|
<param name="value">The byte to write to the stream.</param><summary>Writes a byte to the current position in the stream and advances the position within the stream by one byte.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Use the <xref:Microsoft.Data.SqlTypes.SqlFileStream.CanWrite%2A> property to determine whether the current instance supports writing.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.NotSupportedException">The object does not support writing of data.</exception><related type="Article" href="https://msdn.microsoft.com/library/bd8b845c-0f09-4295-b466-97ef106eefa8">FILESTREAM Data in SQL Server 2008 (ADO.NET)</related>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.ActiveDirectoryAuthenticationProvider">
|
||
|
<summary>
|
||
|
This class implements <see cref="T:Microsoft.Data.SqlClient.SqlAuthenticationProvider" /> and is used for active directory federated authentication mechanisms.
|
||
|
</summary>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.ActiveDirectoryAuthenticationProvider.#ctor">
|
||
|
<summary>
|
||
|
Initializes the <see cref="T:Microsoft.Data.SqlClient.ActiveDirectoryAuthenticationProvider" /> class.
|
||
|
</summary>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.ActiveDirectoryAuthenticationProvider.#ctor(System.String)">
|
||
|
<param name="applicationClientId">Client Application Id to be used for acquiring an access token for federated authentication. The driver uses its own application client id by default.</param><summary>
|
||
|
Initializes the <see cref="T:Microsoft.Data.SqlClient.ActiveDirectoryAuthenticationProvider" /> class with the provided application client id.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown">
|
||
|
<![CDATA[
|
||
|
|
||
|
## Examples
|
||
|
The following example demonstrates providing a user-defined application client id to SqlClient for the "Active Directory Interactive" authentication method:
|
||
|
|
||
|
[!code-csharp[ActiveDirectory_ApplicationClientId Example#1](~/../sqlclient/doc/samples/ApplicationClientIdAzureAuthenticationProvider.cs#1)]
|
||
|
|
||
|
]]>
|
||
|
</format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.ActiveDirectoryAuthenticationProvider.ClearUserTokenCache">
|
||
|
<summary>Clears cached user tokens from the token provider.</summary><remarks>This will cause interactive authentication prompts to appear again if tokens were previously being obtained from the cache.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.ActiveDirectoryAuthenticationProvider.#ctor(System.Func{Microsoft.Identity.Client.DeviceCodeResult,System.Threading.Tasks.Task},System.String)">
|
||
|
<param name="deviceCodeFlowCallbackMethod">The callback method to be used with 'Active Directory Device Code Flow' authentication.</param><param name="applicationClientId">(Optional) Client Application Id to be used for acquiring an access token for federated authentication. The driver uses its own application client id by default.</param><summary>
|
||
|
Initializes the <see cref="T:Microsoft.Data.SqlClient.ActiveDirectoryAuthenticationProvider" /> class with the provided device code flow callback method and application client id.
|
||
|
</summary>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.ActiveDirectoryAuthenticationProvider.AcquireTokenAsync(Microsoft.Data.SqlClient.SqlAuthenticationParameters)">
|
||
|
<param name="parameters">The Active Directory authentication parameters passed to authentication providers.</param><summary>Acquires a security token from the authority.</summary><returns>Represents an asynchronous operation that returns the authentication token.</returns>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.ActiveDirectoryAuthenticationProvider.SetDeviceCodeFlowCallback(System.Func{Microsoft.Identity.Client.DeviceCodeResult,System.Threading.Tasks.Task})">
|
||
|
<param name="deviceCodeFlowCallbackMethod">The callback method to be used with 'Active Directory Device Code Flow' authentication.</param><summary>Sets the callback method, overriding the default implementation that processes the result for 'Active Directory Device Code Flow' authentication.</summary><remarks>
|
||
|
<format type="text/markdown">
|
||
|
<![CDATA[
|
||
|
|
||
|
## Examples
|
||
|
The following example demonstrates providing a custom device flow callback to SqlClient for the Device Code Flow authentication method:
|
||
|
|
||
|
[!code-csharp[ActiveDirectory_DeviceCodeFlowCallback Example#1](~/../sqlclient/doc/samples/AADAuthenticationCustomDeviceFlowCallback.cs#1)]
|
||
|
|
||
|
]]>
|
||
|
</format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.ActiveDirectoryAuthenticationProvider.SetAcquireAuthorizationCodeAsyncCallback(System.Func{System.Uri,System.Uri,System.Threading.CancellationToken,System.Threading.Tasks.Task{System.Uri}})">
|
||
|
<param name="acquireAuthorizationCodeAsyncCallback">The callback method to be called by MSAL.NET to delegate the Web user interface with the Secure Token Service (STS).</param><summary>Sets a callback method which is invoked with a custom Web UI instance that will let the user sign-in with Azure Active Directory, present consent if needed, and get back the authorization code. Applicable when working with Active Directory Interactive authentication.</summary><remarks>The "authorizationUri" is crafted to leverage PKCE in order to protect the token from a man in the middle attack. Only MSAL.NET can redeem the code. In the event of cancellation, the implementer should return <see cref="T:System.OperationCanceledException" />.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.ActiveDirectoryAuthenticationProvider.IsSupported(Microsoft.Data.SqlClient.SqlAuthenticationMethod)">
|
||
|
<param name="authentication">The authentication method.</param><summary>Indicates whether the specified authentication method is supported.</summary><returns>
|
||
|
<see langword="true" /> if the specified authentication method is supported; otherwise, <see langword="false" />.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown">
|
||
|
<![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The supported authentication modes with <xref=Microsoft.Data.SqlClient.ActiveDirectoryAuthenticationProvider> are:
|
||
|
|
||
|
- Active Directory Password
|
||
|
- Active Directory Integrated
|
||
|
- Active Directory Interactive
|
||
|
- Active Directory Service Principal
|
||
|
- Active Directory Device Code Flow
|
||
|
- Active Directory Managed Identity
|
||
|
- Active Directory MSI
|
||
|
- Active Directory Default
|
||
|
|
||
|
]]>
|
||
|
</format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.ActiveDirectoryAuthenticationProvider.BeforeLoad(Microsoft.Data.SqlClient.SqlAuthenticationMethod)">
|
||
|
<param name="authentication">The authentication method.</param><summary>This method is called immediately before the provider is added to authentication provider registry. </summary><remarks>Avoid performing long-waiting tasks in this method, since it can block other threads from accessing the provider registry.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.ActiveDirectoryAuthenticationProvider.BeforeUnload(Microsoft.Data.SqlClient.SqlAuthenticationMethod)">
|
||
|
<param name="authentication">The authentication method.</param><summary>This method is called immediately before the provider is removed from the authentication provider registry. </summary><remarks>For example, this method is called when a different provider with the same authentication method overrides this provider in the authentication provider registry. Avoid performing long-waiting task in this method, since it can block other threads from accessing the provider registry.</remarks>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.ApplicationIntent">
|
||
|
<summary>
|
||
|
Specifies a value for <see cref="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.ApplicationIntent" />. Possible values are <see langword="ReadWrite" /> and <see langword="ReadOnly" />.
|
||
|
</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.ApplicationIntent.ReadOnly">
|
||
|
<summary>The application workload type when connecting to a server is read only.</summary><returns>1</returns><value>1</value>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.ApplicationIntent.ReadWrite">
|
||
|
<summary>The application workload type when connecting to a server is read write.</summary><returns>0</returns><value>0</value>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.PoolBlockingPeriod">
|
||
|
<summary>Specifies a value for the <see cref="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.PoolBlockingPeriod" /> property. </summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.PoolBlockingPeriod.Auto">
|
||
|
<summary>Blocking period OFF for Azure SQL servers, but ON for all other SQL servers.</summary><value>0</value>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.PoolBlockingPeriod.AlwaysBlock">
|
||
|
<summary>Blocking period ON for all SQL servers including Azure SQL servers.</summary><value>1</value>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.PoolBlockingPeriod.NeverBlock">
|
||
|
<summary>Blocking period OFF for Azure SQL servers, but ON for all other SQL servers.</summary><value>2</value>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.OnChangeEventHandler">
|
||
|
<OnChangeEventHandler>
|
||
|
<param name="sender">The source of the event.</param>
|
||
|
<param name="e">A <see cref="T:Microsoft.Data.SqlClient.SqlNotificationEventArgs" /> object that contains the event data.</param>
|
||
|
<summary>Handles the <see cref="E:Microsoft.Data.SqlClient.SqlDependency.OnChange" /> event that is fired when a notification is received for any of the commands associated with a <see cref="T:Microsoft.Data.SqlClient.SqlDependency" /> object.</summary>
|
||
|
<remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlDependency.OnChange> event does not necessarily imply a change in the data. Other circumstances, such as time-out expired and failure to set the notification request, also generate <xref:Microsoft.Data.SqlClient.SqlDependency.OnChange>.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</OnChangeEventHandler>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SortOrder">
|
||
|
<summary>
|
||
|
Specifies how rows of data are sorted.
|
||
|
</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SortOrder.Unspecified">
|
||
|
<summary>The default. No sort order is specified.</summary><value>-1</value><returns>-1</returns>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SortOrder.Ascending">
|
||
|
<summary>Rows are sorted in ascending order.</summary><value>0</value><returns>0</returns>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SortOrder.Descending">
|
||
|
<summary>Rows are sorted in descending order.</summary><value>1</value><returns>1</returns>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlAuthenticationInitializer">
|
||
|
<summary>Called from constructors in derived classes to initialize the <see cref="T:Microsoft.Data.SqlClient.SqlAuthenticationInitializer" /> class.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlAuthenticationInitializer.#ctor">
|
||
|
<summary>Default Constructor to initialize the <see cref="T:Microsoft.Data.SqlClient.SqlAuthenticationInitializer" /> class.</summary>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlAuthenticationInitializer.Initialize">
|
||
|
<summary>When overridden in a derived class, initializes the authentication initializer. This method is called by the <see cref="M:Microsoft.Data.SqlClient.SqlAuthenticationInitializer.#ctor" /> constructor during startup.</summary>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlAuthenticationMethod">
|
||
|
<summary>Describes the different SQL authentication methods that can be used by a client connecting to Azure SQL Database. For details, see <see href="https://docs.microsoft.com/azure/sql-database/sql-database-aad-authentication">Connecting to SQL Database By Using Azure Active Directory Authentication</see>.
|
||
|
</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlAuthenticationMethod.NotSpecified">
|
||
|
<summary>The authentication method is not specified.</summary><value>0</value>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlAuthenticationMethod.SqlPassword">
|
||
|
<summary>The authentication method is Sql Password.</summary><value>1</value>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlAuthenticationMethod.ActiveDirectoryPassword">
|
||
|
<summary>The authentication method uses Active Directory Password. Use Active Directory Password to connect to a SQL Database using an Azure AD principal name and password.</summary><value>2</value>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlAuthenticationMethod.ActiveDirectoryIntegrated">
|
||
|
<summary>The authentication method uses Active Directory Integrated. Use Active Directory Integrated to connect to a SQL Database using integrated Windows authentication.</summary><value>3</value>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlAuthenticationMethod.ActiveDirectoryInteractive">
|
||
|
<summary>The authentication method uses Active Directory Interactive. Use Active Directory Interactive to connect to a SQL Database with an interactive authentication flow.</summary><value>4</value>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlAuthenticationMethod.ActiveDirectoryServicePrincipal">
|
||
|
<summary>The authentication method uses Active Directory Service Principal. Use Active Directory Service Principal to connect to a SQL Database using the client ID and secret of a service principal identity.</summary><value>5</value>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlAuthenticationMethod.ActiveDirectoryDeviceCodeFlow">
|
||
|
<summary>The authentication method uses Active Directory Device Code Flow. Use Active Directory Device Code Flow to connect to a SQL Database from devices and operating systems that do not provide a Web browser, using another device to perform interactive authentication.</summary><value>6</value>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlAuthenticationMethod.ActiveDirectoryManagedIdentity">
|
||
|
<summary>The authentication method uses Active Directory Managed Identity. Use System Assigned or User Assigned Managed Identity to connect to SQL Database from Azure client environments that have enabled support for Managed Identity. For User Assigned Managed Identity, 'User Id' or 'UID' is required to be set to the "client ID" of the user identity.</summary><value>7</value>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlAuthenticationMethod.ActiveDirectoryMSI">
|
||
|
<summary>Alias for "Active Directory Managed Identity" authentication method. Use System Assigned or User Assigned Managed Identity to connect to SQL Database from Azure client environments that have enabled support for Managed Identity. For User Assigned Managed Identity, 'User Id' or 'UID' is required to be set to the "client ID" of the user identity.</summary><value>8</value>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlAuthenticationMethod.ActiveDirectoryDefault">
|
||
|
<summary>The authentication method uses Active Directory Default. Use this mode to connect to a SQL Database using multiple non-interactive authentication methods tried sequentially to acquire an access token. This method does not fallback to the "Active Directory Interactive" authentication method.</summary><value>9</value>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlAuthenticationMethod.ActiveDirectoryWorkloadIdentity">
|
||
|
<summary>The authentication method uses Active Directory Workload Identity. Use a federated User Assigned Managed Identity to connect to SQL Database from Azure client environments that have enabled support for Workload Identity. The 'User Id' or 'UID' is required to be set to the "client ID" of the user identity.</summary><value>10</value>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlAuthenticationParameters">
|
||
|
<summary>Represents AD authentication parameters passed by a driver to authentication providers.</summary>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlAuthenticationParameters.#ctor(Microsoft.Data.SqlClient.SqlAuthenticationMethod,System.String,System.String,System.String,System.String,System.String,System.String,System.Guid,System.Int32)">
|
||
|
<param name="authenticationMethod">One of the enumeration values that specifies the authentication method.</param><param name="serverName">The server name.</param><param name="databaseName">The database name.</param><param name="resource">The resource URI.</param><param name="authority">The authority URI.</param><param name="userId">The user login name/ID.</param><param name="password">The user password.</param><param name="connectionId">The connection ID.</param><param name="connectionTimeout">The connection timeout value in seconds.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.SqlAuthenticationParameters" /> class using the specified authentication method, server name, database name, resource URI, authority URI, user login name/ID, user password, connection ID and connection timeout value.</summary>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlAuthenticationParameters.AuthenticationMethod">
|
||
|
<summary>Gets the authentication method.</summary><value>The authentication method.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlAuthenticationParameters.Authority">
|
||
|
<summary>Gets the authority URI.</summary><value>The authority URI.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlAuthenticationParameters.ConnectionId">
|
||
|
<summary>Gets the connection ID.</summary><value>The connection ID.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlAuthenticationParameters.DatabaseName">
|
||
|
<summary>Gets the database name.</summary><value>The database name.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlAuthenticationParameters.Password">
|
||
|
<summary>Gets the user password.</summary><value>The user password.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlAuthenticationParameters.Resource">
|
||
|
<summary>The resource URIs.</summary><value>The resource URI.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlAuthenticationParameters.ServerName">
|
||
|
<summary>Gets the server name.</summary><value>The server name.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlAuthenticationParameters.UserId">
|
||
|
<summary>Gets the user login name/ID.</summary><value>The user login name/ID.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlAuthenticationParameters.ConnectionTimeout">
|
||
|
<summary>Gets the connection timeout value.</summary><value>The connection timeout value to be passed to Cancellation Token Source.</value>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlAuthenticationProvider">
|
||
|
<summary>Defines the core behavior of authentication providers and provides a base class for derived classes. </summary><remarks>
|
||
|
<format type="text/markdown">
|
||
|
<![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Derived classes must provide a parameterless constructor if they can be instantiated from the app.config file.
|
||
|
|
||
|
## Examples
|
||
|
The following example demonstrates implementing a custom SqlAuthenticationProvider and providing the same to SqlClient for overriding Device Code Flow authentication mode:
|
||
|
|
||
|
[!code-csharp[ActiveDirectory_DeviceCodeFlowCallback Example#1](~/../sqlclient/doc/samples/CustomDeviceCodeFlowAzureAuthenticationProvider.cs#1)]
|
||
|
|
||
|
]]>
|
||
|
</format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlAuthenticationProvider.#ctor">
|
||
|
<summary>
|
||
|
Called from constructors in derived classes to initialize the <see cref="T:Microsoft.Data.SqlClient.SqlAuthenticationProvider" /> class.
|
||
|
</summary>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlAuthenticationProvider.AcquireTokenAsync(Microsoft.Data.SqlClient.SqlAuthenticationParameters)">
|
||
|
<param name="parameters">The Active Directory authentication parameters passed by the driver to authentication providers.</param><summary>Acquires a security token from the authority.</summary><returns>Represents an asynchronous operation that returns the AD authentication token.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlAuthenticationProvider.BeforeLoad(Microsoft.Data.SqlClient.SqlAuthenticationMethod)">
|
||
|
<param name="authenticationMethod">The authentication method.</param><summary>This method is called immediately before the provider is added to SQL drivers registry. </summary><remarks>Avoid performing long-waiting tasks in this method, since it can block other threads from accessing the provider registry.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlAuthenticationProvider.BeforeUnload(Microsoft.Data.SqlClient.SqlAuthenticationMethod)">
|
||
|
<param name="authenticationMethod">The authentication method.</param><summary>This method is called immediately before the provider is removed from the SQL drivers registry. </summary><remarks>For example, this method is called when a different provider with the same authentication method overrides this provider in the SQL drivers registry. Avoid performing long-waiting task in this method, since it can block other threads from accessing the provider registry.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlAuthenticationProvider.GetProvider(Microsoft.Data.SqlClient.SqlAuthenticationMethod)">
|
||
|
<param name="authenticationMethod">The authentication method.</param><summary>Gets an authentication provider by method.</summary><returns>
|
||
|
The authentication provider or <see langword="null" /> if not found.
|
||
|
</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlAuthenticationProvider.IsSupported(Microsoft.Data.SqlClient.SqlAuthenticationMethod)">
|
||
|
<param name="authenticationMethod">The authentication method.</param><summary>Indicates whether the specified authentication method is supported.</summary><returns>
|
||
|
<see langword="true" /> if the specified authentication method is supported; otherwise, <see langword="false" />.
|
||
|
</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlAuthenticationProvider.SetProvider(Microsoft.Data.SqlClient.SqlAuthenticationMethod,Microsoft.Data.SqlClient.SqlAuthenticationProvider)">
|
||
|
<param name="authenticationMethod">The authentication method.</param><param name="provider">The authentication provider.</param><summary>Sets an authentication provider by method.</summary><returns>
|
||
|
<see langword="true" /> if the operation succeeded; otherwise, <see langword="false" /> (for example, the existing provider disallows overriding).
|
||
|
</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlAuthenticationToken">
|
||
|
<summary>Represents an AD authentication token.</summary>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlAuthenticationToken.#ctor(System.String,System.DateTimeOffset)">
|
||
|
<param name="accessToken">The access token.</param><param name="expiresOn">The token expiration time.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.SqlAuthenticationToken" /> class.</summary><exception cref="T:System.ArgumentNullException">The <paramref name="accessToken" />parameter is <see langword="null" />or empty.</exception>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlAuthenticationToken.AccessToken">
|
||
|
<summary>Gets the token string.</summary><value>The token string.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlAuthenticationToken.ExpiresOn">
|
||
|
<summary>Gets the token expiration time.</summary><value>The token expiration time.</value>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlBulkCopy">
|
||
|
<summary>
|
||
|
Lets you efficiently bulk load a SQL Server table with data from another source.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Microsoft SQL Server includes a popular command-prompt utility named **bcp** for moving data from one table to another, whether on a single server or between servers. The <xref:Microsoft.Data.SqlClient.SqlBulkCopy> class lets you write managed code solutions that provide similar functionality. There are other ways to load data into a SQL Server table (INSERT statements, for example), but <xref:Microsoft.Data.SqlClient.SqlBulkCopy> offers a significant performance advantage over them. The <xref:Microsoft.Data.SqlClient.SqlBulkCopy> class can be used to write data only to SQL Server tables. However, the data source is not limited to SQL Server; any data source can be used, as long as the data can be loaded to a <xref:System.Data.DataTable> instance or read with a <xref:System.Data.IDataReader> instance. <xref:Microsoft.Data.SqlClient.SqlBulkCopy> will fail when bulk loading a <xref:System.Data.DataTable> column of type <xref:System.Data.SqlTypes.SqlDateTime> into a SQL Server column whose type is one of the date/time types added in SQL Server 2008.
|
||
|
|
||
|
## Examples
|
||
|
The following console application demonstrates how to load data using the <xref:Microsoft.Data.SqlClient.SqlBulkCopy> class.
|
||
|
In this example, a <xref:Microsoft.Data.SqlClient.SqlDataReader> is used to copy data from the **Production.Product** table in the SQL Server **AdventureWorks** database to a similar table in the same database.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance,
|
||
|
it is easier and faster to use a Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[BulkCopy.Single#1](~/../sqlclient/doc/samples/SqlBulkCopy_Single.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopy.#ctor(Microsoft.Data.SqlClient.SqlConnection)">
|
||
|
<param name="connection">
|
||
|
The already open
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
instance that will be used to perform the bulk copy operation. If your connection string does not use
|
||
|
<see langword="Integrated Security = true" />
|
||
|
, you can use
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlCredential" />
|
||
|
to pass the user ID and password more securely than by specifying the user ID and password as text in the connection string.
|
||
|
</param><summary>
|
||
|
Initializes a new instance of the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />
|
||
|
class using the specified open instance of
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Because the connection is already open when the <xref:Microsoft.Data.SqlClient.SqlBulkCopy> instance is initialized, the connection remains open after the <xref:Microsoft.Data.SqlClient.SqlBulkCopy> instance is closed.
|
||
|
If the `connection` argument is null, an <xref:System.ArgumentNullException> is thrown.
|
||
|
|
||
|
## Examples
|
||
|
The following console application demonstrates how to bulk load data using a connection that is already open. In this example, a <xref:Microsoft.Data.SqlClient.SqlDataReader>
|
||
|
is used to copy data from the **Production.Product** table in the SQL Server **AdventureWorks** database to a similar table in the same database. This example is for demonstration
|
||
|
purposes only. You would not use `SqlBulkCopy` to move data from one table to another in the same database in a production application.
|
||
|
Note that the source data does not have to be located on SQL Server; you can use any data source that can be read to an <xref:System.Data.IDataReader> or loaded to a
|
||
|
<xref:System.Data.DataTable>.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to use a
|
||
|
Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[BulkCopy.Single#1](~/../sqlclient/doc/samples/SqlBulkCopy_Single.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopy.#ctor(Microsoft.Data.SqlClient.SqlConnection,Microsoft.Data.SqlClient.SqlBulkCopyOptions,Microsoft.Data.SqlClient.SqlTransaction)">
|
||
|
<param name="connection">
|
||
|
The already open
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
instance that will be used to perform the bulk copy. If your connection string does not use
|
||
|
<see langword="Integrated Security = true" />
|
||
|
, you can use
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlCredential" />
|
||
|
to pass the user ID and password more securely than by specifying the user ID and password as text in the connection string.
|
||
|
</param><param name="copyOptions">
|
||
|
A combination of values from the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyOptions" />
|
||
|
enumeration that determines which data source rows are copied to the destination table.
|
||
|
</param><param name="externalTransaction">
|
||
|
An existing
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlTransaction" />
|
||
|
instance under which the bulk copy will occur.
|
||
|
</param><summary>
|
||
|
Initializes a new instance of the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />
|
||
|
class using the supplied existing open instance of
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
. The
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />
|
||
|
instance behaves according to options supplied in the
|
||
|
<paramref name="copyOptions" />
|
||
|
parameter. If a non-null
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlTransaction" />
|
||
|
is supplied, the copy operations will be performed within that transaction.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
If options include `UseInternalTransaction` and the `externalTransaction` argument is not null, an **InvalidArgumentException** is thrown.
|
||
|
|
||
|
For examples demonstrating how to use `SqlBulkCopy` in a transaction, see [Transaction and Bulk Copy Operations](/sql/connect/ado-net/sql/transaction-bulk-copy-operations).
|
||
|
]]></format>
|
||
|
</remarks><related type="Article" href="https://msdn.microsoft.com/library/83a7a0d2-8018-4354-97b9-0b1d99f8342b">
|
||
|
Performing Bulk Copy Operations
|
||
|
</related><related type="Article" href="/sql/connect/ado-net/overview-sqlclient-driver">
|
||
|
Overview of the SqlClient driver
|
||
|
</related>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopy.#ctor(System.String)">
|
||
|
<param name="connectionString">
|
||
|
The string defining the connection that will be opened for use by the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />
|
||
|
instance.
|
||
|
If your connection string does not use
|
||
|
<see langword="Integrated Security = true" />
|
||
|
, you can use
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.#ctor(Microsoft.Data.SqlClient.SqlConnection)" />
|
||
|
or
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.#ctor(Microsoft.Data.SqlClient.SqlConnection,Microsoft.Data.SqlClient.SqlBulkCopyOptions,Microsoft.Data.SqlClient.SqlTransaction)" />
|
||
|
and
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlCredential" />
|
||
|
to pass the user ID and password more securely than by specifying the user ID and password as text in the connection string.
|
||
|
</param><summary>
|
||
|
Initializes and opens a new instance of
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
based on the supplied
|
||
|
<paramref name="connectionString" />
|
||
|
. The constructor uses the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
to initialize a new instance of the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />
|
||
|
class.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The connection is automatically closed at the end of the bulk copy operation.
|
||
|
If `connectionString` is null, an <xref:System.ArgumentNullException> is thrown. If `connectionString` is an empty string, an <xref:System.ArgumentException> is thrown.
|
||
|
|
||
|
## Examples
|
||
|
The following console application demonstrates how to bulk load data by using a connection specified as a string. The connection is automatically
|
||
|
closed when the <xref:Microsoft.Data.SqlClient.SqlBulkCopy> instance is closed.
|
||
|
In this example, the source data is first read from a SQL Server table to a <xref:Microsoft.Data.SqlClient.SqlDataReader> instance.
|
||
|
The source data does not have to be located on SQL Server; you can use any data source that can be read to an <xref:System.Data.IDataReader> or loaded to a <xref:System.Data.DataTable>.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance,
|
||
|
it is easier and faster to use a Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.ConnectionString#1](~/../sqlclient/doc/samples/SqlBulkCopy_ConnectionString.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentException">
|
||
|
If `connectionString` is an empty string, an
|
||
|
<see cref="T:System.ArgumentException" />
|
||
|
is thrown.
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopy.#ctor(System.String,Microsoft.Data.SqlClient.SqlBulkCopyOptions)">
|
||
|
<param name="connectionString">
|
||
|
The string defining the connection that will be opened for use by the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />
|
||
|
instance. If your connection string does not use
|
||
|
<see langword="Integrated Security = true" />
|
||
|
, you can use
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.#ctor(Microsoft.Data.SqlClient.SqlConnection)" />
|
||
|
or
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.#ctor(Microsoft.Data.SqlClient.SqlConnection,Microsoft.Data.SqlClient.SqlBulkCopyOptions,Microsoft.Data.SqlClient.SqlTransaction)" />
|
||
|
and
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlCredential" />
|
||
|
to pass the user ID and password more securely than by specifying the user ID and password as text in the connection string.
|
||
|
</param><param name="copyOptions">
|
||
|
A combination of values from the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyOptions" />
|
||
|
enumeration that determines which data source rows are copied to the destination table.
|
||
|
</param><summary>
|
||
|
Initializes and opens a new instance of
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
based on the supplied
|
||
|
<paramref name="connectionString" />
|
||
|
. The constructor uses that
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
to initialize a new instance of the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />
|
||
|
class. The
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
instance behaves according to options supplied in the
|
||
|
<paramref name="copyOptions" />
|
||
|
parameter.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
You can obtain detailed information about all the bulk copy options in the <xref:Microsoft.Data.SqlClient.SqlBulkCopyOptions> topic.
|
||
|
|
||
|
## Examples
|
||
|
The following console application demonstrates how to perform a bulk load by using a connection specified as a string.
|
||
|
An option is set to use the value in the identity column of the source table when you load the destination table. In this example,
|
||
|
the source data is first read from a SQL Server table to a <xref:Microsoft.Data.SqlClient.SqlDataReader> instance.
|
||
|
The source table and destination table each include an Identity column. By default, a new value for the **Identity** column is generated in the destination table for each row added.
|
||
|
In this example, an option is set when the connection is opened that forces the bulk load process to use the **Identity** values from the source table instead.
|
||
|
To see how the option changes the way the bulk load works, run the sample with the **dbo.BulkCopyDemoMatchingColumns** table empty. All rows load from the source.
|
||
|
Then run the sample again without emptying the table. An exception is thrown and the code writes a message to the console notifying you that rows weren't
|
||
|
added because of primary key constraint violations.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup). This code is provided to
|
||
|
demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to use a Transact-SQL `INSERT … SELECT` statement
|
||
|
to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.KeepIdentity#1](~/../sqlclient/doc/samples/SqlBulkCopy_KeepIdentity.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBulkCopy.BatchSize">
|
||
|
<summary>
|
||
|
Number of rows in each batch. At the end of each batch, the rows in the batch are sent to the server.
|
||
|
</summary><value>
|
||
|
The integer value of the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlBulkCopy.BatchSize" />
|
||
|
property, or zero if no value has been set.
|
||
|
</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
A batch is complete when <xref:Microsoft.Data.SqlClient.SqlBulkCopy.BatchSize> rows have been processed or there are no more rows to send to the destination data source.
|
||
|
|
||
|
Zero (the default) indicates that each <xref:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer%2A> operation is a single batch.
|
||
|
|
||
|
If the <xref:Microsoft.Data.SqlClient.SqlBulkCopy> instance has been declared without the <xref:Microsoft.Data.SqlClient.SqlBulkCopyOptions.UseInternalTransaction> option in effect,
|
||
|
rows are sent to the server <xref:Microsoft.Data.SqlClient.SqlBulkCopy.BatchSize> rows at a time, but no transaction-related action is taken.
|
||
|
If <xref:Microsoft.Data.SqlClient.SqlBulkCopyOptions.UseInternalTransaction> is in effect, each batch of rows is inserted as a separate transaction.
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlBulkCopy.BatchSize> property can be set at any time. If a bulk copy is already in progress, the current batch is sized according to the previous batch size.
|
||
|
Subsequent batches use the new size. If the <xref:Microsoft.Data.SqlClient.SqlBulkCopy.BatchSize> is initially zero and changed while a <xref:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer%2A>
|
||
|
operation is already in progress, that operation loads the data as a single batch. Any subsequent <xref:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer%2A>
|
||
|
operations on the same <xref:Microsoft.Data.SqlClient.SqlBulkCopy> instance use the new <xref:Microsoft.Data.SqlClient.SqlBulkCopy.BatchSize>.
|
||
|
|
||
|
## Examples
|
||
|
The following console application demonstrates how to bulk load data in batches of 50 rows. For an example illustrating how <xref:Microsoft.Data.SqlClient.SqlBulkCopy.BatchSize>
|
||
|
works with a transaction, see [Transaction and Bulk Copy Operations](/sql/connect/ado-net/sql/transaction-bulk-copy-operations).
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance,
|
||
|
it is easier and faster to use a Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.BatchSize#1](~/../sqlclient/doc/samples/SqlBulkCopy_BatchSize.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBulkCopy.BulkCopyTimeout">
|
||
|
<summary>
|
||
|
Number of seconds for the operation to complete before it times out.
|
||
|
</summary><value>
|
||
|
The integer value of the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlBulkCopy.BulkCopyTimeout" />
|
||
|
property. The default is 30 seconds. A value of 0 indicates no limit; the bulk copy will wait indefinitely.
|
||
|
</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
If the operation does time out, the transaction is not committed and all copied rows are removed from the destination table.
|
||
|
|
||
|
## Examples
|
||
|
The following console application demonstrates how to modify the time-out to 60 seconds when bulk loading data.
|
||
|
In this example, the source data is first read from a SQL Server table to a <xref:Microsoft.Data.SqlClient.SqlDataReader> instance.
|
||
|
The source data does not have to be located on SQL Server; you can use any data source that can be read to an <xref:System.Data.IDataReader> or loaded to a <xref:System.Data.DataTable>.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to use a
|
||
|
Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.Timeout#1](~/../sqlclient/doc/samples/SqlBulkCopy_Timeout.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBulkCopy.EnableStreaming">
|
||
|
<summary>
|
||
|
Enables or disables a
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />
|
||
|
object to stream data from an
|
||
|
<see cref="T:System.Data.IDataReader" />
|
||
|
object
|
||
|
</summary><value>
|
||
|
<see langword="true" />
|
||
|
if a
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />
|
||
|
object can stream data from an
|
||
|
<see cref="T:System.Data.IDataReader" />
|
||
|
object; otherwise, false. The default is
|
||
|
<see langword="false" />
|
||
|
.
|
||
|
</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
When <xref:Microsoft.Data.SqlClient.SqlBulkCopy.EnableStreaming> is `true`, <xref:Microsoft.Data.SqlClient.SqlBulkCopy> reads from an <xref:System.Data.IDataReader> object using <xref:System.Data.CommandBehavior.SequentialAccess>,
|
||
|
optimizing memory usage by using the <xref:System.Data.IDataReader> streaming capabilities. Streaming is only applicable to max data types (i.e.
|
||
|
VARBINARY(MAX), VARCHAR(MAX), NVARCHAR(MAX), and XML). When <xref:Microsoft.Data.SqlClient.SqlBulkCopy.EnableStreaming> is set to false,
|
||
|
the <xref:Microsoft.Data.SqlClient.SqlBulkCopy> class loads all the data returned by the <xref:System.Data.IDataReader> object into memory before sending it to the server.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> The main advantage of enabling streaming is reducing memory usage during bulk copy of max data types.
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBulkCopy.ColumnMappings">
|
||
|
<summary>
|
||
|
Returns a collection of
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping" />
|
||
|
items. Column mappings define the relationships between columns in the data source and columns in the destination.
|
||
|
</summary><value>
|
||
|
A collection of column mappings. By default, it is an empty collection.
|
||
|
</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
If the data source and the destination table have the same number of columns, and the ordinal position of each source column within the data source matches the ordinal position of
|
||
|
the corresponding destination column, the <xref:Microsoft.Data.SqlClient.SqlBulkCopy.ColumnMappings> collection is unnecessary. However, if the column counts differ,
|
||
|
or the ordinal positions are not consistent, you must use <xref:Microsoft.Data.SqlClient.SqlBulkCopy.ColumnMappings> to make sure that data is copied into the correct columns.
|
||
|
|
||
|
During the execution of a bulk copy operation, this collection can be accessed, but it cannot be changed. Any attempt to change it will throw an <xref:System.InvalidOperationException>.
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBulkCopy.ColumnOrderHints">
|
||
|
<summary>
|
||
|
Returns a collection of
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint" />
|
||
|
items. Column order hints describe the sort order of columns in the clustered index of the destination table.
|
||
|
</summary><value>
|
||
|
A collection of column order hints. By default, it is an empty collection.
|
||
|
</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
SqlBulkCopy's performance is improved if the data being imported is sorted according to the clustered index on the table, if any.
|
||
|
If the data is sorted in an order that differs from the order of a clustered index key or if there is no clustered index on the table, the order hint is ignored.
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBulkCopy.DestinationTableName">
|
||
|
<summary>
|
||
|
Name of the destination table on the server.
|
||
|
</summary><value>
|
||
|
The string value of the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlBulkCopy.DestinationTableName" />
|
||
|
property, or null if none as been supplied.
|
||
|
</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
## Remarks
|
||
|
If <xref:Microsoft.Data.SqlClient.SqlBulkCopy.DestinationTableName> has not been set when <xref:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer%2A> is called, an <xref:System.ArgumentNullException>
|
||
|
is thrown. If <xref:Microsoft.Data.SqlClient.SqlBulkCopy.DestinationTableName> is modified while a <xref:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer%2A> operation is running,
|
||
|
the change does not affect the current operation. The new <xref:Microsoft.Data.SqlClient.SqlBulkCopy.DestinationTableName> value is used the next time a <xref:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer%2A> method is called.
|
||
|
|
||
|
<xref:Microsoft.Data.SqlClient.SqlBulkCopy.DestinationTableName> is a three-part name (`<database>.<owningschema>.<name>`). You can qualify the table name with its database and owning schema if you choose.
|
||
|
However, if the table name uses an underscore ("_") or any other special characters, you must escape the name using surrounding brackets as in (`[<database>.<owningschema>.<name_01>]`).
|
||
|
|
||
|
You can bulk-copy data to a temporary table by using a value such as `tempdb..#table` or `tempdb.<owner>.#table` for the <xref:Microsoft.Data.SqlClient.SqlBulkCopy.DestinationTableName> property.
|
||
|
|
||
|
## Examples
|
||
|
The following console application demonstrates how to bulk load data using a connection that is already open. The destination table is a table in the **AdventureWorks** database.
|
||
|
|
||
|
In this example, the connection is first used to read data from a SQL Server table to a <xref:Microsoft.Data.SqlClient.SqlDataReader> instance. The source data does not have to
|
||
|
be located on SQL Server; you can use any data source that can be read to an <xref:System.Data.IDataReader> or loaded to a <xref:System.Data.DataTable>.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance,
|
||
|
it is easier and faster to use a Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
[!code-csharp[SqlBulkCopy.Single#1](~/../sqlclient/doc/samples/SqlBulkCopy_Single.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBulkCopy.NotifyAfter">
|
||
|
<summary>
|
||
|
Defines the number of rows to be processed before generating a notification event.
|
||
|
</summary><value>
|
||
|
The integer value of the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlBulkCopy.NotifyAfter" />
|
||
|
property, or zero if the property has not been set.
|
||
|
</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This property is designed for user interface components that illustrate the progress of a bulk copy operation. It indicates the number of rows to be processed before generating a notification event.
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlBulkCopy.NotifyAfter> property can be set at any time, even while a bulk copy operation is underway. Changes made during a bulk copy operation take effect after
|
||
|
the next notification. The new setting applies to all subsequent operations on the same instance.
|
||
|
|
||
|
If <xref:Microsoft.Data.SqlClient.SqlBulkCopy.NotifyAfter> is set to a number less than zero, an <xref:System.ArgumentOutOfRangeException> is thrown.
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following console application demonstrates how to bulk load data using a connection that is already open. The <xref:Microsoft.Data.SqlClient.SqlBulkCopy.NotifyAfter> property is set so that
|
||
|
the event handler is called after every 50 rows copied to the table.
|
||
|
|
||
|
In this example, the connection is first used to read data from a SQL Server table to a <xref:Microsoft.Data.SqlClient.SqlDataReader> instance. Then a second connection is opened to bulk copy the data.
|
||
|
Note that the source data does not have to be located on SQL Server; you can use any data source that can be read to an <xref:System.Data.IDataReader> or loaded to a <xref:System.Data.DataTable>.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup). This code is provided to
|
||
|
demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to use a Transact-SQL `INSERT … SELECT`
|
||
|
statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.NotifyAfter#1](~/../sqlclient/doc/samples/SqlBulkCopy_NotifyAfter.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBulkCopy.RowsCopied">
|
||
|
<summary>
|
||
|
The number of rows processed in the ongoing bulk copy operation.
|
||
|
</summary><value>
|
||
|
The integer value of the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlBulkCopy.RowsCopied" />
|
||
|
property.
|
||
|
</value><remarks>
|
||
|
<format type="text/markdown">
|
||
|
<![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This value is incremented during the <xref:Microsoft.Data.SqlClient.SqlBulkCopy.SqlRowsCopied> event and does not imply that this number of rows has been sent to the server or committed.
|
||
|
|
||
|
This value can be accessed during or after the execution of a bulk copy operation.
|
||
|
|
||
|
This value will wrap around and become negative if the number of rows exceeds int.MaxValue. Consider using the <xref:Microsoft.Data.SqlClient.SqlBulkCopy.RowsCopied64> property.
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBulkCopy.RowsCopied64">
|
||
|
<summary>
|
||
|
The number of rows processed in the ongoing bulk copy operation.
|
||
|
</summary><value>
|
||
|
The long value of the <see cref="P:Microsoft.Data.SqlClient.SqlBulkCopy.RowsCopied64" /> property.
|
||
|
</value><remarks>
|
||
|
<format type="text/markdown">
|
||
|
<![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This value is incremented during the <xref:Microsoft.Data.SqlClient.SqlBulkCopy.SqlRowsCopied> event and does not imply that this number of rows has been sent to the server or committed.
|
||
|
|
||
|
This value can be accessed during or after the execution of a bulk copy operation.
|
||
|
]]>
|
||
|
</format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="E:Microsoft.Data.SqlClient.SqlBulkCopy.SqlRowsCopied">
|
||
|
<summary>
|
||
|
Occurs every time that the number of rows specified by the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlBulkCopy.NotifyAfter" />
|
||
|
property have been processed.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
|
||
|
Note that the settings of <xref:Microsoft.Data.SqlClient.SqlBulkCopy.NotifyAfter> and <xref:Microsoft.Data.SqlClient.SqlBulkCopy.BatchSize> are independent. Receipt of a
|
||
|
<xref:Microsoft.Data.SqlClient.SqlBulkCopy.SqlRowsCopied> event does not imply that any rows have been sent to the server or committed.
|
||
|
|
||
|
You cannot call SqlBulkCopy.Close (<xref:Microsoft.Data.SqlClient.SqlBulkCopy.Close>) or SqlConnection.Close (<xref:Microsoft.Data.SqlClient.SqlConnection.Close>) from this event.
|
||
|
Doing this will cause an <xref:System.InvalidOperationException> being thrown, and the <xref:Microsoft.Data.SqlClient.SqlBulkCopy> object state will not change. If the user wants to cancel the
|
||
|
operation from the event, the <xref:Microsoft.Data.SqlClient.SqlRowsCopiedEventArgs.Abort> property of the <xref:Microsoft.Data.SqlClient.SqlRowsCopiedEventArgs> can be used.
|
||
|
(See [Transaction and Bulk Copy Operations](/sql/connect/ado-net/sql/transaction-bulk-copy-operations) for examples that use the
|
||
|
<xref:Microsoft.Data.SqlClient.SqlRowsCopiedEventArgs.Abort> property.)
|
||
|
|
||
|
No action, such as transaction activity, is supported in the connection during the execution of the bulk copy operation, and it is recommended that you not use the same connection used
|
||
|
during the <xref:Microsoft.Data.SqlClient.SqlBulkCopy.SqlRowsCopied> event. However, you can open a different connection.
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following console application demonstrates how to bulk load data using a connection that is already open. The <xref:Microsoft.Data.SqlClient.SqlBulkCopy.NotifyAfter> property is set so that
|
||
|
the event handler is called after every 50 rows copied to the table.
|
||
|
|
||
|
In this example, the connection is first used to read data from a SQL Server table to a <xref:Microsoft.Data.SqlClient.SqlDataReader> instance. Note that the source data does not have to be located on
|
||
|
SQL Server; you can use any data source that can be read to an <xref:System.Data.IDataReader> or loaded to a <xref:System.Data.DataTable>.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance, it is easier
|
||
|
and faster to use a Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.NotifyAfter#1](~/../sqlclient/doc/samples/SqlBulkCopy_NotifyAfter.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopy.Close">
|
||
|
<summary>
|
||
|
Closes the <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" /> instance.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
After you call a <xref:Microsoft.Data.SqlClient.SqlBulkCopy.Close> on the <xref:Microsoft.Data.SqlClient.SqlBulkCopy> object, no other operation will succeed. Calls to the <xref:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer%2A> method will throw an <xref:System.InvalidOperationException>. Calling the <xref:Microsoft.Data.SqlClient.SqlBulkCopy.Close> method from the <xref:Microsoft.Data.SqlClient.SqlBulkCopy.SqlRowsCopied> event causes an <xref:System.InvalidOperationException> to be thrown.
|
||
|
Note that open <xref:Microsoft.Data.SqlClient.SqlBulkCopy> instances are closed implicitly at the end of a `using` block.
|
||
|
|
||
|
## Examples
|
||
|
The following example uses the same <xref:Microsoft.Data.SqlClient.SqlBulkCopy> instance to add sales orders and their associated details to two destination tables. Because the **AdventureWorks** sales order tables are large, the sample reads only orders placed by a certain account number and bulk copies those orders and details to the destination tables. The <xref:Microsoft.Data.SqlClient.SqlBulkCopy.Close> method is used only after both bulk copy operations are complete.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup). This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to use a Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.OrdersDetails#1](~/../sqlclient/doc/samples/SqlBulkCopy_OrdersDetails.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopy.System#IDisposable#Dispose">
|
||
|
<summary>
|
||
|
Releases all resources used by the current instance of the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />
|
||
|
class.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
Call `Dispose` when you are finished using the <xref:Microsoft.Data.SqlClient.SqlBulkCopy>. The `Dispose` method leaves the <xref:Microsoft.Data.SqlClient.SqlBulkCopy> in an unusable state.
|
||
|
After calling `Dispose`, you must release all references to the <xref:Microsoft.Data.SqlClient.SqlBulkCopy> so the garbage collector can reclaim the memory that the
|
||
|
<xref:Microsoft.Data.SqlClient.SqlBulkCopy> was occupying.
|
||
|
|
||
|
For more information, see [Cleaning Up Unmanaged Resources](/dotnet/standard/garbage-collection/unmanaged) and
|
||
|
[Implementing a Dispose Method](/dotnet/standard/garbage-collection/implementing-dispose).
|
||
|
|
||
|
> [!NOTE]
|
||
|
> Always call `Dispose` before you release your last reference to the <xref:Microsoft.Data.SqlClient.SqlBulkCopy>. Otherwise, the resources it is using will not be freed until the garbage collector calls
|
||
|
the <xref:Microsoft.Data.SqlClient.SqlBulkCopy> object's `Finalize` method.
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer(System.Data.Common.DbDataReader)">
|
||
|
<param name="reader">
|
||
|
A
|
||
|
<see cref="T:System.Data.Common.DbDataReader" />
|
||
|
whose rows will be copied to the destination table.
|
||
|
</param><summary>
|
||
|
Copies all rows from the supplied
|
||
|
<see cref="T:System.Data.Common.DbDataReader" />
|
||
|
array to a destination table specified by the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlBulkCopy.DestinationTableName" />
|
||
|
property of the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />
|
||
|
object.
|
||
|
</summary><remarks>
|
||
|
To be added.
|
||
|
</remarks><exception cref="T:System.InvalidOperationException">
|
||
|
A
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint" />
|
||
|
did not specify a valid destination column name.
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer(System.Data.DataTable)">
|
||
|
<param name="table">
|
||
|
A
|
||
|
<see cref="T:System.Data.DataTable" />
|
||
|
whose rows will be copied to the destination table.
|
||
|
</param><summary>
|
||
|
Copies all rows in the supplied
|
||
|
<see cref="T:System.Data.DataTable" />
|
||
|
to a destination table specified by the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlBulkCopy.DestinationTableName" />
|
||
|
property of the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />
|
||
|
object.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
All rows in the <xref:System.Data.DataTable> are copied to the destination table except those that have been deleted.
|
||
|
|
||
|
While the bulk copy operation is in progress, the associated destination <xref:Microsoft.Data.SqlClient.SqlConnection> is busy serving it, and no other operations can be performed on the connection.
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlBulkCopy.ColumnMappings> collection maps from the <xref:System.Data.DataTable> columns to the destination database table.
|
||
|
|
||
|
## Examples
|
||
|
The following Console application demonstrates how to bulk load data from a <xref:System.Data.DataTable>. The destination table is a table in the **AdventureWorks** database.
|
||
|
|
||
|
In this example, a <xref:System.Data.DataTable> is created at run time and is the source of the `SqlBulkCopy` operation.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to use a Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.DataTable#1](~/../sqlclient/doc/samples/SqlBulkCopy_DataTable.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidOperationException">
|
||
|
A
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint" />
|
||
|
did not specify a valid destination column name.
|
||
|
</exception><related type="Article" href="https://msdn.microsoft.com/library/83a7a0d2-8018-4354-97b9-0b1d99f8342b">
|
||
|
Performing Bulk Copy Operations
|
||
|
</related><related type="Article" href="/sql/connect/ado-net/overview-sqlclient-driver">
|
||
|
Overview of the SqlClient driver
|
||
|
</related>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer(System.Data.DataTable,System.Data.DataRowState)">
|
||
|
<param name="table">
|
||
|
A
|
||
|
<see cref="T:System.Data.DataTable" />
|
||
|
whose rows will be copied to the destination table.
|
||
|
</param><param name="rowState">
|
||
|
A value from the
|
||
|
<see cref="T:System.Data.DataRowState" />
|
||
|
enumeration. Only rows matching the row state are copied to the destination.
|
||
|
</param><summary>
|
||
|
Copies only rows that match the supplied row state in the supplied
|
||
|
<see cref="T:System.Data.DataTable" />
|
||
|
to a destination table specified by the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlBulkCopy.DestinationTableName" />
|
||
|
property of the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />
|
||
|
object.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
## Remarks
|
||
|
|
||
|
Only rows in the <xref:System.Data.DataTable> that are in the states indicated in the `rowState` argument and have not been deleted are copied to the destination table.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> If <xref:System.Data.DataRowState.Deleted> is specified, any <xref:System.Data.DataRowState.Unchanged>, <xref:System.Data.DataRowState.Added>, and <xref:System.Data.DataRowState.Modified>
|
||
|
rows will also be copied to the server. No exception will be raised.
|
||
|
|
||
|
While the bulk copy operation is in progress, the associated destination <xref:Microsoft.Data.SqlClient.SqlConnection> is busy serving it, and no other operations can be performed on the connection.
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlBulkCopy.ColumnMappings> collection maps from the <xref:System.Data.DataTable> columns to the destination database table.
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following Console application demonstrates how to bulk load only the rows in a <xref:System.Data.DataTable> that match a specified state. In this case, only unchanged rows are added. The destination table is a table in the **AdventureWorks** database.
|
||
|
|
||
|
In this example, a <xref:System.Data.DataTable> is created at run time and three rows are added to it. Before the <xref:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer%2A> method is executed, one of the rows is edited.
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer%2A> method is called with a `DataRowState.Unchanged` `rowState` argument, so only the two unchanged rows are bulk copied to the destination.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup). This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to use a Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.DataRowState#1](~/../sqlclient/doc/samples/SqlBulkCopy_DataRowState.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidOperationException">
|
||
|
A
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint" />
|
||
|
did not specify a valid destination column name.
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer(System.Data.DataRow[])">
|
||
|
<param name="rows">An array of <see cref="T:System.Data.DataRow" /> objects that will be copied to the destination table.</param><summary>Copies all rows from the supplied <see cref="T:System.Data.DataRow" /> array to a destination table specified by the <see cref="P:Microsoft.Data.SqlClient.SqlBulkCopy.DestinationTableName" /> property of the <see cref="T:System.Data.SqlClient.SqlBulkCopy" /> object.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
While the bulk copy operation is in progress, the associated destination <xref:Microsoft.Data.SqlClient.SqlConnection> is busy serving it, and no other operations can be performed on the connection.
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlBulkCopy.ColumnMappings> collection maps from the <xref:System.Data.DataRow> columns to the destination database table.
|
||
|
|
||
|
## Examples
|
||
|
The following console application demonstrates how to bulk load data from a <xref:System.Data.DataRow> array. The destination table is a table in the **AdventureWorks** database.
|
||
|
|
||
|
In this example, a <xref:System.Data.DataTable> is created at run time. A single row is selected from the <xref:System.Data.DataTable> to copy to the destination table.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup). This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to use a Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.RowArray#1](~/../sqlclient/doc/samples/SqlBulkCopy_RowArray.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidOperationException">
|
||
|
A
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint" />
|
||
|
did not specify a valid destination column name.
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer(System.Data.IDataReader)">
|
||
|
<param name="reader">
|
||
|
A
|
||
|
<see cref="T:System.Data.IDataReader" />
|
||
|
whose rows will be copied to the destination table.
|
||
|
</param><summary>
|
||
|
Copies all rows in the supplied
|
||
|
<see cref="T:System.Data.IDataReader" />
|
||
|
to a destination table specified by the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlBulkCopy.DestinationTableName" />
|
||
|
property of the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />
|
||
|
object.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
## Remarks
|
||
|
The copy operation starts at the next available row in the reader. Most of the time, the reader was just returned by <xref:System.Data.IDbCommand.ExecuteReader> or a similar call,
|
||
|
so the next available row is the first row. To process multiple results, call <xref:System.Data.IDataReader.NextResult> on the data reader and call
|
||
|
<xref:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer%2A> again.
|
||
|
|
||
|
Note that using <xref:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer%2A> modifies the state of the reader. The method will call <xref:System.Data.IDataReader.Read>
|
||
|
until it returns false, the operation is aborted, or an error occurs. This means that the data reader will be in a different state, probably at the end of the result set,
|
||
|
when the <xref:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer%2A> operation is complete.
|
||
|
|
||
|
While the bulk copy operation is in progress, the associated destination <xref:Microsoft.Data.SqlClient.SqlConnection> is busy serving it, and no other operations can be performed on the connection.
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlBulkCopy.ColumnMappings> collection maps from the data reader columns to the destination database table.
|
||
|
|
||
|
## Examples
|
||
|
The following console application demonstrates how to bulk load data from a <xref:Microsoft.Data.SqlClient.SqlDataReader>. The destination table is a table in the **AdventureWorks** database.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup). This code is provided
|
||
|
to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to use a
|
||
|
Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.ConnectionString#1](~/../sqlclient/doc/samples/SqlBulkCopy_ConnectionString.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidOperationException">
|
||
|
A
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint" />
|
||
|
did not specify a valid destination column name.
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.Common.DbDataReader)">
|
||
|
<param name="reader">
|
||
|
A
|
||
|
<see cref="T:System.Data.IDataReader" />
|
||
|
whose rows will be copied to the destination table.
|
||
|
</param><summary>
|
||
|
The asynchronous version of
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer(System.Data.IDataReader)" />,
|
||
|
which copies all rows in the supplied
|
||
|
<see cref="T:System.Data.IDataReader" />
|
||
|
to a destination table specified by the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlBulkCopy.DestinationTableName" />
|
||
|
property of the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />
|
||
|
object.
|
||
|
</summary><returns>
|
||
|
A task representing the asynchronous operation.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see [Asynchronous Programming](/sql/connect/ado-net/asynchronous-programming).
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidOperationException">
|
||
|
Calling
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.IDataReader)" />
|
||
|
multiple times for the same instance before task completion.
|
||
|
|
||
|
Calling
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.IDataReader)" />
|
||
|
and
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer(System.Data.IDataReader)" />
|
||
|
for the same instance before task completion.
|
||
|
|
||
|
The connection drops or is closed during
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.IDataReader)" />
|
||
|
execution.
|
||
|
|
||
|
Returned in the task object, the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />
|
||
|
object was closed during the method execution.
|
||
|
|
||
|
Returned in the task object, there was a connection pool timeout.
|
||
|
|
||
|
Returned in the task object, the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
object is closed before method execution.
|
||
|
|
||
|
The
|
||
|
<see cref="T:System.Data.IDataReader" />
|
||
|
was closed before the completed
|
||
|
<see cref="T:System.Threading.Tasks.Task" />
|
||
|
returned.
|
||
|
|
||
|
The
|
||
|
<see cref="T:System.Data.IDataReader" />'s associated connection was closed before the completed
|
||
|
<see cref="T:System.Threading.Tasks.Task" />
|
||
|
returned.
|
||
|
|
||
|
A
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint" />
|
||
|
did not specify a valid destination column name.
|
||
|
</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">
|
||
|
Returned in the task object, any error returned by SQL Server that occurred while opening the connection.
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.Common.DbDataReader,System.Threading.CancellationToken)">
|
||
|
<param name="reader">
|
||
|
A
|
||
|
<see cref="T:System.Data.Common.DbDataReader" />
|
||
|
whose rows will be copied to the destination table.
|
||
|
</param><param name="cancellationToken">
|
||
|
The cancellation instruction. A
|
||
|
<see cref="P:System.Threading.CancellationToken.None" />
|
||
|
value in this parameter makes this method equivalent to
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.Common.DbDataReader)" />.
|
||
|
</param><summary>
|
||
|
The asynchronous version of
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer(System.Data.Common.DbDataReader)" />,
|
||
|
which copies all rows from the supplied
|
||
|
<see cref="T:System.Data.Common.DbDataReader" />
|
||
|
array to a destination table specified by the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlBulkCopy.DestinationTableName" />
|
||
|
property of the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />
|
||
|
object.
|
||
|
|
||
|
The cancellation token can be used to request that the operation be abandoned before the command timeout elapses. Exceptions will be reported via the returned Task object.
|
||
|
</summary><returns>
|
||
|
A task representing the asynchronous operation.
|
||
|
</returns><remarks>
|
||
|
To be added.
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.DataRow[])">
|
||
|
<param name="rows">
|
||
|
An array of
|
||
|
<see cref="T:System.Data.DataRow" />
|
||
|
objects that will be copied to the destination table.
|
||
|
</param><summary>
|
||
|
The asynchronous version of
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer(System.Data.DataRow[])" />,
|
||
|
which copies all rows from the supplied
|
||
|
<see cref="T:System.Data.DataRow" />
|
||
|
array to a destination table specified by the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlBulkCopy.DestinationTableName" />
|
||
|
property of the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />
|
||
|
object.
|
||
|
</summary><returns>
|
||
|
A task representing the asynchronous operation.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see [Asynchronous Programming](/sql/connect/ado-net/asynchronous-programming).
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidOperationException">
|
||
|
Calling
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.DataRow[])" />
|
||
|
multiple times for the same instance before task completion. Calling
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.DataRow[])" />
|
||
|
and
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer(System.Data.DataRow[])" />
|
||
|
for the same instance before task completion.
|
||
|
|
||
|
The connection drops or is closed during
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.DataRow[])" />
|
||
|
execution.
|
||
|
|
||
|
Returned in the task object, the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />
|
||
|
object was closed during the method execution.
|
||
|
|
||
|
Returned in the task object, there was a connection pool timeout.
|
||
|
|
||
|
Returned in the task object, the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
object is closed before method execution.
|
||
|
|
||
|
A
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint" />
|
||
|
did not specify a valid destination column name.
|
||
|
</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">
|
||
|
Returned in the task object, any error returned by SQL Server that occurred while opening the connection.
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.DataRow[],System.Threading.CancellationToken)">
|
||
|
<param name="rows">
|
||
|
An array of
|
||
|
<see cref="T:System.Data.DataRow" />
|
||
|
objects that will be copied to the destination table.
|
||
|
</param><param name="cancellationToken">
|
||
|
The cancellation instruction. A
|
||
|
<see cref="P:System.Threading.CancellationToken.None" />
|
||
|
value in this parameter makes this method equivalent to
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.DataTable)" />.
|
||
|
</param><summary>
|
||
|
The asynchronous version of
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer(System.Data.DataRow[])" />,
|
||
|
which copies all rows from the supplied
|
||
|
<see cref="T:System.Data.DataRow" />
|
||
|
array to a destination table specified by the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlBulkCopy.DestinationTableName" />
|
||
|
property of the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />
|
||
|
object.
|
||
|
|
||
|
The cancellation token can be used to request that the operation be abandoned before the command timeout elapses. Exceptions will be reported via the returned Task object.
|
||
|
</summary><returns>
|
||
|
A task representing the asynchronous operation.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see [Asynchronous Programming](/sql/connect/ado-net/asynchronous-programming).
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidOperationException">
|
||
|
Calling
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.DataRow[])" />
|
||
|
multiple times for the same instance before task completion.
|
||
|
|
||
|
Calling
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.DataRow[])" />
|
||
|
and
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer(System.Data.DataRow[])" />
|
||
|
for the same instance before task completion.
|
||
|
|
||
|
The connection drops or is closed during
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.DataRow[])" />
|
||
|
execution.
|
||
|
|
||
|
Returned in the task object, the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />
|
||
|
object was closed during the method execution.
|
||
|
|
||
|
Returned in the task object, there was a connection pool timeout.
|
||
|
|
||
|
Returned in the task object, the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
object is closed before method execution.
|
||
|
|
||
|
A
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint" />
|
||
|
did not specify a valid destination column name.
|
||
|
</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">
|
||
|
Returned in the task object, any error returned by SQL Server that occurred while opening the connection.
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.DataTable)">
|
||
|
<param name="table">
|
||
|
A
|
||
|
<see cref="T:System.Data.DataTable" />
|
||
|
whose rows will be copied to the destination table.
|
||
|
</param><summary>
|
||
|
The asynchronous version of
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer(System.Data.DataTable)" />,
|
||
|
which copies all rows in the supplied
|
||
|
<see cref="T:System.Data.DataTable" />
|
||
|
to a destination table specified by the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlBulkCopy.DestinationTableName" />
|
||
|
property of the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />
|
||
|
object.
|
||
|
</summary><returns>
|
||
|
A task representing the asynchronous operation.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see [Asynchronous Programming](/sql/connect/ado-net/asynchronous-programming).
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidOperationException">
|
||
|
Calling
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.DataTable)" />
|
||
|
multiple times for the same instance before task completion.
|
||
|
|
||
|
Calling
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.DataTable)" />
|
||
|
and
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer(System.Data.DataTable)" />
|
||
|
for the same instance before task completion.
|
||
|
|
||
|
The connection drops or is closed during
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.DataTable)" />
|
||
|
execution.
|
||
|
|
||
|
Returned in the task object, the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />
|
||
|
object was closed during the method execution.
|
||
|
|
||
|
Returned in the task object, there was a connection pool timeout.
|
||
|
|
||
|
Returned in the task object, the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
object is closed before method execution.
|
||
|
|
||
|
A
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint" />
|
||
|
did not specify a valid destination column name.
|
||
|
</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">
|
||
|
Returned in the task object, any error returned by SQL Server that occurred while opening the connection.
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.DataTable,System.Data.DataRowState)">
|
||
|
<param name="table">
|
||
|
A
|
||
|
<see cref="T:System.Data.DataTable" />
|
||
|
whose rows will be copied to the destination table.
|
||
|
</param><param name="rowState">
|
||
|
A value from the
|
||
|
<see cref="T:System.Data.DataRowState" />
|
||
|
enumeration. Only rows matching the row state are copied to the destination.
|
||
|
</param><summary>
|
||
|
The asynchronous version of
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer(System.Data.DataTable,System.Data.DataRowState)" />,
|
||
|
which copies only rows that match the supplied row state in the supplied
|
||
|
<see cref="T:System.Data.DataTable" /> to a destination table specified by the <see cref="P:Microsoft.Data.SqlClient.SqlBulkCopy.DestinationTableName" />
|
||
|
property of the <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" /> object.
|
||
|
</summary><returns>
|
||
|
A task representing the asynchronous operation.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see [Asynchronous Programming](/sql/connect/ado-net/asynchronous-programming).
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidOperationException">
|
||
|
Calling
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.DataTable,System.Data.DataRowState)" />
|
||
|
multiple times for the same instance before task completion.
|
||
|
|
||
|
Calling
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.DataTable,System.Data.DataRowState)" />
|
||
|
and
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer(System.Data.DataTable,System.Data.DataRowState)" />
|
||
|
for the same instance before task completion.
|
||
|
|
||
|
The connection drops or is closed during
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.DataTable,System.Data.DataRowState)" />
|
||
|
execution.
|
||
|
|
||
|
Returned in the task object, the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />
|
||
|
object was closed during the method execution.
|
||
|
|
||
|
Returned in the task object, there was a connection pool timeout.
|
||
|
|
||
|
Returned in the task object, the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
object is closed before method execution.
|
||
|
|
||
|
A
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint" />
|
||
|
did not specify a valid destination column name.
|
||
|
</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">
|
||
|
Returned in the task object, any error returned by SQL Server that occurred while opening the connection.
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.DataTable,System.Data.DataRowState,System.Threading.CancellationToken)">
|
||
|
<param name="table">
|
||
|
A
|
||
|
<see cref="T:System.Data.DataTable" />
|
||
|
whose rows will be copied to the destination table.
|
||
|
</param><param name="rowState">
|
||
|
A value from the
|
||
|
<see cref="T:System.Data.DataRowState" />
|
||
|
enumeration. Only rows matching the row state are copied to the destination.
|
||
|
</param><param name="cancellationToken">
|
||
|
The cancellation instruction. A
|
||
|
<see cref="P:System.Threading.CancellationToken.None" />
|
||
|
value in this parameter makes this method equivalent to
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.DataTable)" />.
|
||
|
</param><summary>
|
||
|
The asynchronous version of
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer(System.Data.DataTable,System.Data.DataRowState)" />,
|
||
|
which copies only rows that match the supplied row state in the supplied
|
||
|
<see cref="T:System.Data.DataTable" />
|
||
|
to a destination table specified by the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlBulkCopy.DestinationTableName" />
|
||
|
property of the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />
|
||
|
object.
|
||
|
|
||
|
The cancellation token can be used to request that the operation be abandoned before the command timeout elapses. Exceptions will be reported via the returned Task object.
|
||
|
</summary><returns>
|
||
|
A task representing the asynchronous operation.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see [Asynchronous Programming](/sql/connect/ado-net/asynchronous-programming).
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidOperationException">
|
||
|
Calling
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.DataTable,System.Data.DataRowState)" />
|
||
|
multiple times for the same instance before task completion.
|
||
|
|
||
|
Calling
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.DataTable,System.Data.DataRowState)" />
|
||
|
and
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer(System.Data.DataTable,System.Data.DataRowState)" />
|
||
|
for the same instance before task completion.
|
||
|
|
||
|
The connection drops or is closed during
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.DataTable,System.Data.DataRowState)" />
|
||
|
execution.
|
||
|
|
||
|
Returned in the task object, the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />
|
||
|
object was closed during the method execution.
|
||
|
|
||
|
Returned in the task object, there was a connection pool timeout.
|
||
|
|
||
|
Returned in the task object, the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
object is closed before method execution.
|
||
|
|
||
|
A
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint" />
|
||
|
did not specify a valid destination column name.
|
||
|
</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">
|
||
|
Returned in the task object, any error returned by SQL Server that occurred while opening the connection.
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.DataTable,System.Threading.CancellationToken)">
|
||
|
<param name="table">
|
||
|
A
|
||
|
<see cref="T:System.Data.DataTable" />
|
||
|
whose rows will be copied to the destination table.
|
||
|
</param><param name="cancellationToken">
|
||
|
The cancellation instruction. A
|
||
|
<see cref="P:System.Threading.CancellationToken.None" />
|
||
|
value in this parameter makes this method equivalent to
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.DataTable)" />.
|
||
|
</param><summary>
|
||
|
The asynchronous version of
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer(System.Data.DataTable)" />,
|
||
|
which copies all rows in the supplied
|
||
|
<see cref="T:System.Data.DataTable" />
|
||
|
to a destination table specified by the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlBulkCopy.DestinationTableName" />
|
||
|
property of the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />
|
||
|
object.
|
||
|
|
||
|
The cancellation token can be used to request that the operation be abandoned before the command timeout elapses. Exceptions will be reported via the returned Task object.
|
||
|
</summary><returns>
|
||
|
A task representing the asynchronous operation.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see [Asynchronous Programming](/sql/connect/ado-net/asynchronous-programming).
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidOperationException">
|
||
|
Calling
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.DataTable)" />
|
||
|
multiple times for the same instance before task completion.
|
||
|
|
||
|
Calling
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.DataTable)" />
|
||
|
and
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer(System.Data.DataTable)" />
|
||
|
for the same instance before task completion.
|
||
|
|
||
|
The connection drops or is closed during
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.DataTable)" />
|
||
|
execution.
|
||
|
|
||
|
Returned in the task object, the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />
|
||
|
object was closed during the method execution.
|
||
|
|
||
|
Returned in the task object, there was a connection pool timeout.
|
||
|
|
||
|
Returned in the task object, the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
object is closed before method execution.
|
||
|
|
||
|
A
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint" />
|
||
|
did not specify a valid destination column name.
|
||
|
</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">
|
||
|
Returned in the task object, any error returned by SQL Server that occurred while opening the connection.
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.IDataReader)">
|
||
|
<param name="reader">
|
||
|
A
|
||
|
<see cref="T:System.Data.IDataReader" />
|
||
|
whose rows will be copied to the destination table.
|
||
|
</param><summary>
|
||
|
The asynchronous version of
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer(System.Data.IDataReader)" />,
|
||
|
which copies all rows in the supplied
|
||
|
<see cref="T:System.Data.IDataReader" />
|
||
|
to a destination table specified by the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlBulkCopy.DestinationTableName" />
|
||
|
property of the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />
|
||
|
object.
|
||
|
</summary><returns>
|
||
|
A task representing the asynchronous operation.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see [Asynchronous Programming](/sql/connect/ado-net/asynchronous-programming).
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidOperationException">
|
||
|
Calling
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.IDataReader)" />
|
||
|
multiple times for the same
|
||
|
instance before task completion.
|
||
|
|
||
|
Calling
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.IDataReader)" />
|
||
|
and
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer(System.Data.IDataReader)" />
|
||
|
for the same instance before task completion.
|
||
|
|
||
|
The connection drops or is closed during
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.IDataReader)" />
|
||
|
execution.
|
||
|
|
||
|
Returned in the task object, the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />
|
||
|
object was closed during the method execution.
|
||
|
|
||
|
Returned in the task object, there was a connection pool timeout.
|
||
|
|
||
|
Returned in the task object, the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
object is closed before method execution.
|
||
|
|
||
|
The
|
||
|
<see cref="T:System.Data.IDataReader" />
|
||
|
was closed before the completed
|
||
|
<see cref="T:System.Threading.Tasks.Task" />
|
||
|
returned.
|
||
|
|
||
|
The
|
||
|
<see cref="T:System.Data.IDataReader" />'s associated connection was closed before the completed
|
||
|
<see cref="T:System.Threading.Tasks.Task" />
|
||
|
returned.
|
||
|
|
||
|
A
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint" />
|
||
|
did not specify a valid destination column name.
|
||
|
</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">
|
||
|
Returned in the task object, any error returned by SQL Server that occurred while opening the connection.
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.IDataReader,System.Threading.CancellationToken)">
|
||
|
<param name="reader">
|
||
|
A
|
||
|
<see cref="T:System.Data.IDataReader" />
|
||
|
whose rows will be copied to the destination table.
|
||
|
</param><param name="cancellationToken">
|
||
|
The cancellation instruction. A
|
||
|
<see cref="P:System.Threading.CancellationToken.None" />
|
||
|
value in this parameter makes this method equivalent to
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.DataTable)" />.
|
||
|
</param><summary>
|
||
|
The asynchronous version of
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer(System.Data.IDataReader)" />,
|
||
|
which copies all rows in the supplied
|
||
|
<see cref="T:System.Data.IDataReader" />
|
||
|
to a destination table specified by the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlBulkCopy.DestinationTableName" />
|
||
|
property of the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />
|
||
|
object.
|
||
|
|
||
|
The cancellation token can be used to request that the operation be abandoned before the command timeout elapses. Exceptions will be reported via the returned Task object.
|
||
|
</summary><returns>
|
||
|
A task representing the asynchronous operation.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see [Asynchronous Programming](/sql/connect/ado-net/asynchronous-programming).
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidOperationException">
|
||
|
Calling
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.IDataReader)" />
|
||
|
multiple times for the same instance before task completion.
|
||
|
|
||
|
Calling
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.IDataReader)" />
|
||
|
and
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer(System.Data.IDataReader)" />
|
||
|
for the same instance before task completion.
|
||
|
|
||
|
The connection drops or is closed during
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServerAsync(System.Data.IDataReader)" />
|
||
|
execution.
|
||
|
|
||
|
Returned in the task object, the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />
|
||
|
object was closed during the method execution.
|
||
|
|
||
|
Returned in the task object, there was a connection pool timeout.
|
||
|
|
||
|
Returned in the task object, the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
object is closed before method execution.
|
||
|
|
||
|
The
|
||
|
<see cref="T:System.Data.IDataReader" />
|
||
|
was closed before the completed
|
||
|
<see cref="T:System.Threading.Tasks.Task" />
|
||
|
returned.
|
||
|
|
||
|
The
|
||
|
<see cref="T:System.Data.IDataReader" />'s associated connection was closed before the completed
|
||
|
<see cref="T:System.Threading.Tasks.Task" />
|
||
|
returned.
|
||
|
|
||
|
A
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint" />
|
||
|
did not specify a valid destination column name.
|
||
|
</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">
|
||
|
Returned in the task object, any error returned by SQL Server that occurred while opening the connection.
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping">
|
||
|
<summary>
|
||
|
Defines the mapping between a column in a
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />
|
||
|
instance's data source and a column in the instance's destination table.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Column mappings define the mapping between data source and the target table.
|
||
|
|
||
|
If mappings are not defined - that is, the <xref:Microsoft.Data.SqlClient.SqlBulkCopy.ColumnMappings%2A> collection is empty - the columns are mapped implicitly based on ordinal position.
|
||
|
For this to work, source and target schemas must match. If they do not, an <xref:System.InvalidOperationException> will be thrown.
|
||
|
|
||
|
If the <xref:Microsoft.Data.SqlClient.SqlBulkCopy.ColumnMappings%2A> collection is not empty, not every column present in the data source has to be specified. Those not mapped by the collection
|
||
|
are ignored.
|
||
|
|
||
|
You can refer to source and target columns by either name or ordinal. You can also mix by-name and by-ordinal column references in the same mappings collection.
|
||
|
|
||
|
## Examples
|
||
|
The following example bulk copies data from a source table in the **AdventureWorks** sample database to a destination table in the same database. Although the number of columns in the
|
||
|
destination matches the number of columns in the source, and each destination column is in the same ordinal position as its corresponding source column, the column names do not match.
|
||
|
<xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping> objects are used to create a column map for the bulk copy.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to use a
|
||
|
Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.ColumnMapping#1](~/../sqlclient/doc/samples/SqlBulkCopy_ColumnMapping.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping.#ctor">
|
||
|
<summary>
|
||
|
Parameterless constructor that initializes a new
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping" />
|
||
|
object.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
If you use this constructor, you must then define the source for the mapping using the <xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping.SourceColumn>
|
||
|
property or the <xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping.SourceOrdinal%2A> property, and define the destination for the mapping using the
|
||
|
<xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping.DestinationColumn%2A> property or the <xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping.DestinationOrdinal%2A> property.
|
||
|
|
||
|
## Examples
|
||
|
The following example bulk copies data from a source table in the **AdventureWorks** sample database to a destination table in the same database.
|
||
|
Although the number of columns in the destination matches the number of columns in the source, the column names and ordinal positions do not match.
|
||
|
<xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping> objects are used to create a column map for the bulk copy.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance,
|
||
|
it is easier and faster to use a Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.ColumnMapping#1](~/../sqlclient/doc/samples/SqlBulkCopy_ColumnMapping.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping.#ctor(System.Int32,System.Int32)">
|
||
|
<param name="sourceColumnOrdinal">
|
||
|
The ordinal position of the source column within the data source.
|
||
|
</param><param name="destinationOrdinal">
|
||
|
The ordinal position of the destination column within the destination table.
|
||
|
</param><summary>
|
||
|
Creates a new column mapping, using column ordinals to refer to source and destination columns.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Examples
|
||
|
The following example bulk copies data from a source table in the **AdventureWorks** sample database to a destination table in the same database.
|
||
|
Although the number of columns in the destination matches the number of columns in the source, the column names and ordinal positions do not match.
|
||
|
<xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping> objects are used to create a column map for the bulk copy based on the ordinal positions of the columns.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance, it is easier
|
||
|
and faster to use a Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.ColumnMappingOrdinal#1](~/../sqlclient/doc/samples/SqlBulkCopy_ColumnMappingOrdinal.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping.#ctor(System.Int32,System.String)">
|
||
|
<param name="sourceColumnOrdinal">
|
||
|
The ordinal position of the source column within the data source.
|
||
|
</param><param name="destinationColumn">
|
||
|
The name of the destination column within the destination table.
|
||
|
</param><summary>
|
||
|
Creates a new column mapping, using a column ordinal to refer to the source column and a column name for the target column.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Examples
|
||
|
The following example bulk copies data from a source table in the **AdventureWorks** sample database to a destination table in the same database. Although the number of columns in
|
||
|
the destination matches the number of columns in the source, the column names and ordinal positions do not match. <xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping> objects are used to create a
|
||
|
column map for the bulk copy.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance, it is easier and
|
||
|
faster to use a Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.ColumnMappingOrdinalName#1](~/../sqlclient/doc/samples/SqlBulkCopy_ColumnMappingOrdinalName.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping.#ctor(System.String,System.Int32)">
|
||
|
<param name="sourceColumn">
|
||
|
The name of the source column within the data source.
|
||
|
</param><param name="destinationOrdinal">
|
||
|
The ordinal position of the destination column within the destination table.
|
||
|
</param><summary>
|
||
|
Creates a new column mapping, using a column name to refer to the source column and a column ordinal for the target column.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Examples
|
||
|
The following example bulk copies data from a source table in the **AdventureWorks** sample database to a destination table in the same database. Although the number of columns in
|
||
|
the destination matches the number of columns in the source, the column names and ordinal positions do not match. <xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping> objects are used to create
|
||
|
a column map for the bulk copy.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup). This code is
|
||
|
provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to
|
||
|
use a Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.ColumnMappingNameOrdinal#1](~/../sqlclient/doc/samples/SqlBulkCopy_ColumnMappingNameOrdinal.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping.#ctor(System.String,System.String)">
|
||
|
<param name="sourceColumn">
|
||
|
The name of the source column within the data source.
|
||
|
</param><param name="destinationColumn">
|
||
|
The name of the destination column within the destination table.
|
||
|
</param><summary>
|
||
|
Creates a new column mapping, using column names to refer to source and destination columns.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Examples
|
||
|
The following example bulk copies data from a source table in the **AdventureWorks** sample database to a destination table in the same database. Although the number of columns in the
|
||
|
destination matches the number of columns in the source, the column names and ordinal positions do not match. <xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping> objects are used to create a
|
||
|
column map for the bulk copy.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to use a
|
||
|
Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.ColumnMapping#1](~/../sqlclient/doc/samples/SqlBulkCopy_ColumnMapping.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping.DestinationColumn">
|
||
|
<summary>
|
||
|
Name of the column being mapped in the destination database table.
|
||
|
</summary><value>
|
||
|
The string value of the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping.DestinationColumn" />
|
||
|
property.
|
||
|
</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping.DestinationColumn%2A> and <xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping.DestinationOrdinal%2A> properties are mutually exclusive.
|
||
|
The last value set takes precedence.
|
||
|
|
||
|
## Examples
|
||
|
The following example bulk copies data from a source table in the **AdventureWorks** sample database to a destination table in the same database.
|
||
|
Although the number of columns in the destination matches the number of columns in the source, the column names and ordinal positions do not match.
|
||
|
<xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping> objects are used to create a column map for the bulk copy.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to use a
|
||
|
Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.ColumnMappingDestinationColumn#1](~/../sqlclient/doc/samples/SqlBulkCopy_ColumnMappingDestinationColumn.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping.DestinationOrdinal">
|
||
|
<summary>
|
||
|
Ordinal value of the destination column within the destination table.
|
||
|
</summary><value>
|
||
|
The integer value of the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping.DestinationOrdinal" />
|
||
|
property, or -1 if the property has not been set.
|
||
|
</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping.DestinationColumn%2A> and <xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping.DestinationOrdinal%2A> properties are mutually exclusive.
|
||
|
The last value set takes precedence.
|
||
|
|
||
|
## Examples
|
||
|
The following example bulk copies data from a source table in the **AdventureWorks** sample database to a destination table in the same database. Although the number of columns in the
|
||
|
destination matches the number of columns in the source, the column names and ordinal positions do not match. <xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping> objects are used to create a
|
||
|
column map for the bulk copy.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to use a
|
||
|
Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.ColumnMappingDestinationOrdinal#1](~/../sqlclient/doc/samples/SqlBulkCopy_ColumnMappingDestinationOrdinal.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping.SourceColumn">
|
||
|
<summary>
|
||
|
Name of the column being mapped in the data source.
|
||
|
</summary><value>
|
||
|
The string value of the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping.SourceColumn" />
|
||
|
property.
|
||
|
</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping.SourceColumn%2A> and <xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping.SourceOrdinal%2A> properties are mutually exclusive.
|
||
|
The last value set takes precedence.
|
||
|
|
||
|
## Examples
|
||
|
The following example bulk copies data from a source table in the **AdventureWorks** sample database to a destination table in the same database. Although the number of columns in the
|
||
|
destination matches the number of columns in the source, the column names and ordinal positions do not match. <xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping> objects are used to create a
|
||
|
column map for the bulk copy.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to use a
|
||
|
Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.ColumnMappingDestinationColumn#1](~/../sqlclient/doc/samples/SqlBulkCopy_ColumnMappingDestinationColumn.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping.SourceOrdinal">
|
||
|
<summary>
|
||
|
The ordinal position of the source column within the data source.
|
||
|
</summary><value>
|
||
|
The integer value of the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping.SourceOrdinal" />
|
||
|
property.
|
||
|
</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping.SourceColumn%2A> and <xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping.SourceOrdinal%2A> properties are mutually exclusive.
|
||
|
The last value set takes precedence.
|
||
|
|
||
|
## Examples
|
||
|
The following example bulk copies data from a source table in the **AdventureWorks** sample database to a destination table in the same database. Although the number of columns in the destination
|
||
|
matches the number of columns in the source, the column names and ordinal positions do not match. <xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping> objects are used to create a column map for the
|
||
|
bulk copy.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to use a
|
||
|
Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.ColumnMappingDestinationOrdinal#1](~/../sqlclient/doc/samples/SqlBulkCopy_ColumnMappingDestinationOrdinal.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnMappingCollection">
|
||
|
<summary>Collection of <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping" /> objects that inherits from <see cref="T:System.Collections.CollectionBase" />.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Column mappings define the mapping between data source and the target table.
|
||
|
|
||
|
If mappings are not defined - that is, the <xref:Microsoft.Data.SqlClient.SqlBulkCopy.ColumnMappings%2A> collection is empty - the columns are mapped implicitly based on ordinal position.
|
||
|
For this to work, source and target schemas must match. If they do not, an <xref:System.InvalidOperationException> is thrown.
|
||
|
|
||
|
If the <xref:Microsoft.Data.SqlClient.SqlBulkCopy.ColumnMappings%2A> collection is not empty, not every column present in the data source has to be specified. Those not mapped by the collection are
|
||
|
ignored.
|
||
|
|
||
|
You can refer to source and target columns by either name or ordinal. You can mix by-name and by-ordinal column references in the same mappings collection.
|
||
|
|
||
|
## Examples
|
||
|
The following example bulk copies data from a source table in the **AdventureWorks** sample database to a destination table in the same database.
|
||
|
Although the number of columns in the destination matches the number of columns in the source, the column names and ordinal positions do not match.
|
||
|
<xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping> are added to the <xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMappingCollection> for the
|
||
|
<xref:Microsoft.Data.SqlClient.SqlBulkCopy> object to create a column map for the bulk copy.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to
|
||
|
use a Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.ColumnMappingCollection#1](~/../sqlclient/doc/samples/SqlBulkCopy_ColumnMappingCollection.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBulkCopyColumnMappingCollection.Item(System.Int32)">
|
||
|
<param name="index">The zero-based index of the <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping" /> to find.</param><summary>Gets the <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping" /> object at the specified index.</summary><value>A <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping" /> object.</value><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopyColumnMappingCollection.Add(Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping)">
|
||
|
<param name="bulkCopyColumnMapping">The <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping" /> object that describes the mapping to be added to the collection.</param><summary>Adds the specified mapping to the <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnMappingCollection" />.</summary><returns>A <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping" /> object.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Examples
|
||
|
The following example bulk copies data from a source table in the **AdventureWorks** sample database to a destination table in the same database.
|
||
|
Although the number of columns in the destination matches the number of columns in the source, the column names and ordinal positions do not match.
|
||
|
<xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping> objects are used to create a column map for the bulk copy.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance,
|
||
|
it is easier and faster to use a Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.ColumnMapping#1](~/../sqlclient/doc/samples/SqlBulkCopy_ColumnMapping.cs)]
|
||
|
|
||
|
]]>
|
||
|
</format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopyColumnMappingCollection.Add(System.Int32,System.Int32)">
|
||
|
<param name="sourceColumnIndex">The ordinal position of the source column within the data source.</param><param name="destinationColumnIndex">The ordinal position of the destination column within the destination table.</param><summary>Creates a new <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping" /> and adds it to the collection, using ordinals to specify both source and destination columns.</summary><returns>A column mapping.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Mappings in a collection must be uniform: either all integer/integer pairs, all string/string pairs, all integer/string pairs, or all string/integer pairs. If you try to add a
|
||
|
mapping that is different from others already in the collection, an <xref:System.InvalidOperationException> is thrown.
|
||
|
|
||
|
## Examples
|
||
|
The following example bulk copies data from a source table in the **AdventureWorks** sample database to a destination table in the same database.
|
||
|
Although the number of columns in the destination matches the number of columns in the source, the column names and ordinal positions do not match.
|
||
|
<xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping> objects are used to create a column map for the bulk copy using the ordinal position of the source and destination columns.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to use a
|
||
|
Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.ColumnMappingCollectionOrdinal#1](~/../sqlclient/doc/samples/SqlBulkCopy_ColumnMappingCollectionOrdinal.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopyColumnMappingCollection.Add(System.Int32,System.String)">
|
||
|
<param name="sourceColumnIndex">The ordinal position of the source column within the data source.</param><param name="destinationColumn">The name of the destination column within the destination table.</param><summary>Creates a new <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping" /> and adds it to the collection, using an ordinal for the source column and a string for the destination column.</summary><returns>A column mapping.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Mappings in a collection must be uniform: either all integer/integer pairs, all string/string pairs, all integer/string pairs, or all string/integer pairs.
|
||
|
If you try to add a mapping that is different from others already in the collection, an <xref:System.InvalidOperationException> is thrown.
|
||
|
|
||
|
## Examples
|
||
|
The following example bulk copies data from a source table in the **AdventureWorks** sample database to a destination table in the same database. Although the number of columns in the
|
||
|
destination matches the number of columns in the source, the column names and ordinal positions do not match. <xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping> objects are used to create a
|
||
|
column map for the bulk copy.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to use a
|
||
|
Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy_ColumnMappingIndexColName#1](~/../sqlclient/doc/samples/SqlBulkCopy_ColumnMappingIndexColName.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopyColumnMappingCollection.Add(System.String,System.Int32)">
|
||
|
<param name="sourceColumn">The name of the source column within the data source.</param><param name="destinationColumnIndex">The ordinal position of the destination column within the destination table.</param><summary>Creates a new <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping" /> and adds it to the collection, using a column name to describe the source column and an ordinal to specify the destination column.</summary><returns>A column mapping.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Mappings in a collection must be uniform: either all integer/integer pairs, all string/string pairs, all integer/string pairs, or all string/integer pairs.
|
||
|
If you try to add a mapping that is different from others already in the collection, an <xref:System.InvalidOperationException> is thrown.
|
||
|
|
||
|
## Examples
|
||
|
The following example bulk copies data from a source table in the **AdventureWorks** sample database to a destination table in the same database.
|
||
|
Although the number of columns in the destination matches the number of columns in the source, the column names and ordinal positions do not match.
|
||
|
<xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping> objects are used to create a column map for the bulk copy.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance,
|
||
|
it is easier and faster to use a Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.ColumnMappingColNameIndex#1](~/../sqlclient/doc/samples/SqlBulkCopy_ColumnMappingColNameIndex.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopyColumnMappingCollection.Add(System.String,System.String)">
|
||
|
<param name="sourceColumn">The name of the source column within the data source.</param><param name="destinationColumn">The name of the destination column within the destination table.</param><summary>Creates a new <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping" /> and adds it to the collection, using column names to specify both source and destination columns.</summary><returns>A column mapping.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Mappings in a collection must be uniform: either all integer/integer pairs, all string/string pairs, all integer/string pairs, or all string/integer pairs.
|
||
|
If you try to add a mapping that is different from others already in the collection, an <xref:System.InvalidOperationException> is thrown.
|
||
|
|
||
|
## Examples
|
||
|
The following example bulk copies data from a source table in the **AdventureWorks** sample database to a destination table in the same database.
|
||
|
Although the number of columns in the destination matches the number of columns in the source, the column names and ordinal positions do not match. The code creates a
|
||
|
<xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping> object by specifying the column names.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance,
|
||
|
it is easier and faster to use a Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.ColumnMappingCollection#1](~/../sqlclient/doc/samples/SqlBulkCopy_ColumnMappingCollection.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopyColumnMappingCollection.Clear">
|
||
|
<summary>Clears the contents of the collection.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMappingCollection.Clear%2A> method is most commonly used when you use a single <xref:Microsoft.Data.SqlClient.SqlBulkCopy>
|
||
|
instance to process more than one bulk copy operation. If you create column mappings for one bulk copy operation, you must clear the
|
||
|
<xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMappingCollection> after the <xref:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer%2A> method and before processing the next bulk copy.
|
||
|
|
||
|
Performing several bulk copies using the same <xref:Microsoft.Data.SqlClient.SqlBulkCopy> instance will usually be more efficient from a performance point of view than using a separate
|
||
|
<xref:Microsoft.Data.SqlClient.SqlBulkCopy> for each operation.
|
||
|
|
||
|
## Examples
|
||
|
The following example performs two bulk copy operations. The first operation copies sales order header information, and the second copies sales order details.
|
||
|
Although not strictly necessary in this example (because the ordinal positions of the source and destination columns do match), the example defines column mappings for each bulk copy operation.
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMappingCollection.Clear%2A> method must be used after the first bulk copy is performed and before the next bulk copy's column mappings are defined.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to use a
|
||
|
Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.ColumnMappingOrdersDetails#1](~/../sqlclient/doc/samples/SqlBulkCopy_ColumnMappingOrdersDetails.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopyColumnMappingCollection.Contains(Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping)">
|
||
|
<param name="value">A valid <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping" /> object.</param><summary>Gets a value indicating whether a specified <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping" /> object exists in the collection.</summary><returns>
|
||
|
<see langword="true" /> if the specified mapping exists in the collection; otherwise <see langword="false" />.</returns>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopyColumnMappingCollection.CopyTo(Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping[],System.Int32)">
|
||
|
<param name="array">The one-dimensional <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping" /> array that is the destination of the elements copied from
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnMappingCollection" />. The array must have zero-based indexing.</param><param name="index">The zero-based index in <paramref name="array" /> at which copying begins.</param><summary>Copies the elements of the <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnMappingCollection" /> to an array of <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping" />
|
||
|
items, starting at a particular index.
|
||
|
</summary>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopyColumnMappingCollection.IndexOf(Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping)">
|
||
|
<param name="value">The <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping" /> object for which to search.</param><summary>Gets the index of the specified <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping" /> object.</summary><returns>The zero-based index of the column mapping, or -1 if the column mapping is not found in the collection.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopyColumnMappingCollection.Insert(System.Int32,Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping)">
|
||
|
<param name="index">Integer value of the location within the <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnMappingCollection" /> at which to insert the new
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping" />.</param><param name="value">
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping" /> object to be inserted in the collection.</param><summary>Insert a new <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping" /> at the index specified.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopyColumnMappingCollection.Remove(Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping)">
|
||
|
<param name="value">
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping" /> object to be removed from the collection.</param><summary>Removes the specified <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping" /> element from the <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnMappingCollection" />.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMappingCollection.Remove%2A> method is most commonly used when you use a single <xref:Microsoft.Data.SqlClient.SqlBulkCopy>
|
||
|
instance to process more than one bulk copy operation. If you create column mappings for one bulk copy operation, you must remove mappings that no longer apply after the
|
||
|
<xref:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer%2A> method is called and before defining mapping for the next bulk copy. You can clear the entire collection by using the
|
||
|
<xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMappingCollection.Clear%2A> method, or remove mappings individually using the <xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMappingCollection.Remove%2A>
|
||
|
method or the <xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMappingCollection.RemoveAt%2A> method.
|
||
|
|
||
|
Performing several bulk copies using the same <xref:Microsoft.Data.SqlClient.SqlBulkCopy> instance will usually be more efficient from a performance point of view than using a separate
|
||
|
<xref:Microsoft.Data.SqlClient.SqlBulkCopy> for each operation.
|
||
|
|
||
|
## Examples
|
||
|
The following example performs two bulk copy operations. The first operation copies sales order header information, and the second copies sales order details.
|
||
|
Although not strictly necessary in this example (because the ordinal positions of the source and destination columns do match), the example defines column mappings for each bulk copy operation.
|
||
|
Both bulk copies include a mapping for the **SalesOrderID**, so rather than clearing the entire collection between bulk copy operations, the example removes all mappings except for the **SalesOrderID**
|
||
|
mapping and then adds the appropriate mappings for the second bulk copy operation.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to use a
|
||
|
Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.ColumnMappingRemove#1](~/../sqlclient/doc/samples/SqlBulkCopy_ColumnMappingRemove.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopyColumnMappingCollection.RemoveAt(System.Int32)">
|
||
|
<param name="index">The zero-based index of the <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnMapping" /> object to be removed from the collection.</param><summary>Removes the mapping at the specified index from the collection.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMappingCollection.RemoveAt%2A> method is most commonly used when you use a single <xref:Microsoft.Data.SqlClient.SqlBulkCopy>
|
||
|
instance to process more than one bulk copy operation. If you create column mappings for one bulk copy operation, you must remove mappings that no longer apply after the
|
||
|
<xref:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer%2A> method is called and before defining mapping for the next bulk copy. You can clear the entire collection by using the
|
||
|
<xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMappingCollection.Clear%2A> method, or remove mappings individually using the <xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMappingCollection.Remove%2A>
|
||
|
method or the <xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnMappingCollection.RemoveAt%2A> method.
|
||
|
|
||
|
Performing several bulk copies using the same <xref:Microsoft.Data.SqlClient.SqlBulkCopy> instance will usually be more efficient from a performance point of view than using a separate
|
||
|
<xref:Microsoft.Data.SqlClient.SqlBulkCopy> for each operation.
|
||
|
|
||
|
## Examples
|
||
|
The following example performs two bulk copy operations. The first operation copies sales order header information, and the second copies sales order details.
|
||
|
Although not strictly necessary in this example (because the ordinal positions of the source and destination columns do match), the example defines column mappings for each bulk copy operation.
|
||
|
Both bulk copies include a mapping for the **SalesOrderID**, so rather than clearing the entire collection between bulk copy operations, the example removes all mappings except for the
|
||
|
**SalesOrderID** mapping and then adds the appropriate mappings for the second bulk copy operation.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to use a
|
||
|
Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.ColumnMappingRemoveAt#1](~/../sqlclient/doc/samples/SqlBulkCopy_ColumnMappingRemoveAt.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint">
|
||
|
<summary>
|
||
|
Defines the sort order for a column in a
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />
|
||
|
instance's destination table, according to the clustered index on the table.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Column order hints define the sort order of the column in the destination table.
|
||
|
|
||
|
SqlBulkCopy's performance is improved if the data being imported is sorted according to the clustered index on the table, if any.
|
||
|
If the data is sorted in an order that differs from the order of a clustered index key or if there is no clustered index on the table, the order hint is ignored.
|
||
|
|
||
|
Order hints can be specified for any number of columns in the destination table. By default, the bulk insert operation assumes the data is
|
||
|
unordered if no hints are provided.
|
||
|
|
||
|
The column names supplied must be valid column names in the destination table. The order in which hints can be specified is arbitrary.
|
||
|
A single column name cannot be specified more than once.
|
||
|
|
||
|
If the <xref:Microsoft.Data.SqlClient.SqlBulkCopy.ColumnMappings> collection is not empty, order hints can only be provided for valid
|
||
|
destination columns which have been mapped.
|
||
|
|
||
|
If a <xref:Microsoft.Data.SqlClient.SortOrder> of Unspecified is given, an <xref:System.ArgumentException> will be thrown.
|
||
|
|
||
|
## Examples
|
||
|
The following example bulk copies data from a source table in the **AdventureWorks** sample database to a destination table in the same database.
|
||
|
A SqlBulkCopyColumnOrderHint object is used to define the sort order for the ProductNumber destination column.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to use a
|
||
|
Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.ColumnOrderHint#1](~/../sqlclient/doc/samples/SqlBulkCopy_ColumnOrderHint.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint.#ctor(System.String,Microsoft.Data.SqlClient.SortOrder)">
|
||
|
<param name="column">
|
||
|
The name of the destination column within the destination table.
|
||
|
</param><param name="sortOrder">
|
||
|
The sort order of the corresponding destination column.
|
||
|
</param><summary>
|
||
|
Creates a new column order hint for the specified destination column.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Examples
|
||
|
The following example bulk copies data from a source table in the **AdventureWorks** sample database to a destination table in the same database.
|
||
|
A SqlBulkCopyColumnOrderHint object is used to define the sort order for the ProductNumber destination column.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to use a
|
||
|
Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.ColumnOrderHint#1](~/../sqlclient/doc/samples/SqlBulkCopy_ColumnOrderHint.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint.Column">
|
||
|
<summary>
|
||
|
Name of the destination column in the destination table for which the hint is being provided.
|
||
|
</summary><value>
|
||
|
The string value of the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint.Column" />
|
||
|
property.
|
||
|
</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
|
||
|
An <xref:System.ArgumentException> will be thrown if a null or empty string is given.
|
||
|
|
||
|
## Examples
|
||
|
The following example bulk copies data from a source table in the **AdventureWorks** sample database to a destination table in the same database.
|
||
|
A SqlBulkCopyColumnOrderHint object is used to define the sort order for the ProductNumber destination column.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to use a
|
||
|
Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.ColumnOrderHintColumn#1](~/../sqlclient/doc/samples/SqlBulkCopy_ColumnOrderHintColumn.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentException">The value is null or empty.</exception>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint.SortOrder">
|
||
|
<summary>
|
||
|
The sort order of the destination column in the destination table.
|
||
|
</summary><value>
|
||
|
The SortOrder value of the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint.SortOrder" />
|
||
|
property.
|
||
|
</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
An <xref:System.ArgumentException> will be thrown if a <xref:Microsoft.Data.SqlClient.SortOrder> of Unspecified is given.
|
||
|
|
||
|
## Examples
|
||
|
The following example bulk copies data from a source table in the **AdventureWorks** sample database to a destination table in the same database.
|
||
|
A SqlBulkCopyColumnOrderHint object is used to define the sort order for the ProductNumber destination column.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to use a
|
||
|
Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.ColumnOrderHintSortOrder#1](~/../sqlclient/doc/samples/SqlBulkCopy_ColumnOrderHintSortOrder.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentException">The sort order cannot be unspecified for a column order hint.</exception>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHintCollection">
|
||
|
<summary>Collection of <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint" /> objects that inherits from <see cref="T:System.Collections.CollectionBase" />.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Column order hints define the sort order of the column in the destination table.
|
||
|
|
||
|
SqlBulkCopy's performance is improved if the data being imported is sorted according to the clustered index on the table, if any.
|
||
|
If the data is sorted in an order that differs from the order of a clustered index key or if there is no clustered index on the table, the order hint is ignored.
|
||
|
|
||
|
Order hints can be specified for any number of columns in the destination table. By default, the bulk insert operation assumes the data is
|
||
|
unordered if no hints are provided.
|
||
|
|
||
|
The column names supplied must be valid column names in the destination table. The order in which hints can be specified is arbitrary.
|
||
|
A single column name cannot be specified more than once.
|
||
|
|
||
|
If the <xref:Microsoft.Data.SqlClient.SqlBulkCopy.ColumnMappings> collection is not empty, order hints can only be provided for valid
|
||
|
destination columns which have been mapped.
|
||
|
|
||
|
If a <xref:Microsoft.Data.SqlClient.SortOrder> of Unspecified is given, an <xref:System.ArgumentException> will be thrown.
|
||
|
|
||
|
## Examples
|
||
|
|
||
|
The following example bulk copies data from a source table in the **AdventureWorks** sample database to a destination table in the same database.
|
||
|
<xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint>s are added to the <xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHintCollection> of the
|
||
|
<xref:Microsoft.Data.SqlClient.SqlBulkCopy> object to specify order hints for the bulk copy operation.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to
|
||
|
use a Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.ColumnOrderHintCollection#1](~/../sqlclient/doc/samples/SqlBulkCopy_ColumnOrderHintCollection.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHintCollection.Item(System.Int32)">
|
||
|
<param name="index">The zero-based index of the <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint" /> to find.</param><summary>Gets the <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint" /> object at the specified index.</summary><value>A <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint" /> object.</value><remarks>To be added.</remarks><exception cref="T:System.ArgumentOutOfRangeException">The index must be non-negative and less than the size of the collection.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHintCollection.Add(Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint)">
|
||
|
<param name="columnOrderHint">The <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint" /> object that describes the order hint to be added to the collection.</param><summary>Adds the specified order hint to the <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHintCollection" />.</summary><returns>A <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint" /> object.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Examples
|
||
|
The following example bulk copies data from a source table in the **AdventureWorks** sample database to a destination table in the same database.
|
||
|
A SqlBulkCopyColumnOrderHint object is used to define the sort order for the **ProductNumber** destination column.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance,
|
||
|
it is easier and faster to use a Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.ColumnOrderHintCollectionAdd#1](~/../sqlclient/doc/samples/SqlBulkCopy_ColumnOrderHintCollectionAdd.cs)]
|
||
|
|
||
|
]]>
|
||
|
</format>
|
||
|
</remarks><exception cref="T:System.ArgumentException">The value is null.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHintCollection.Add(System.String,Microsoft.Data.SqlClient.SortOrder)">
|
||
|
<param name="column">The name of the destination column within the destination table.</param><param name="sortOrder">The sort order of the corresponding destination column.</param><summary>Creates a new <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint" /> and adds it to the collection.</summary><returns>A column column order hint.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
|
||
|
## Examples
|
||
|
The following example bulk copies data from a source table in the **AdventureWorks** sample database to a destination table in the same database.
|
||
|
A SqlBulkCopyColumnOrderHint object is added to the <xref:Microsoft.Data.SqlClient.SqlBulkCopy.ColumnOrderHints> by providing the destination column name and its sort order.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to use a
|
||
|
Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.ColumnOrderHintCollectionAdd2#1](~/../sqlclient/doc/samples/SqlBulkCopy_ColumnOrderHintCollectionAdd2.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHintCollection.Clear">
|
||
|
<summary>Clears the contents of the collection.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHintCollection.Clear> method is most commonly used when you use a single <xref:Microsoft.Data.SqlClient.SqlBulkCopy>
|
||
|
instance to process more than one bulk copy operation. If you create column order hints for one bulk copy operation, you must clear the
|
||
|
<xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHintCollection> after the <xref:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer> method and before processing the next bulk copy.
|
||
|
|
||
|
Performing several bulk copies using the same <xref:Microsoft.Data.SqlClient.SqlBulkCopy> instance will usually be more efficient from a performance point of view than using a separate
|
||
|
<xref:Microsoft.Data.SqlClient.SqlBulkCopy> for each operation.
|
||
|
|
||
|
## Examples
|
||
|
The following example performs two bulk copy operations. The first operation copies sales order header information, and the second copies sales order details.
|
||
|
The example defines a column order hint for each bulk copy operation.
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHintCollection.Clear> method must be used after the first bulk copy is performed and before the next bulk copy's order hint is defined.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to use a
|
||
|
Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.ColumnOrderHintCollectionClear#1](~/../sqlclient/doc/samples/SqlBulkCopy_ColumnOrderHintCollectionClear.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHintCollection.Contains(Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint)">
|
||
|
<param name="value">A valid <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint" /> object.</param><summary>Gets a value indicating whether a specified <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint" /> object exists in the collection.</summary><returns>
|
||
|
<see langword="true" /> if the specified column order hint exists in the collection; otherwise <see langword="false" />.</returns>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHintCollection.CopyTo(Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint[],System.Int32)">
|
||
|
<param name="array">The one-dimensional <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint" /> array that is the destination of the elements copied from
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHintCollection" />. The array must have zero-based indexing.</param><param name="index">The zero-based index in <paramref name="array" /> at which copying begins.</param><summary>Copies the elements of the <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHintCollection" /> to an array of <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint" />
|
||
|
items, starting at a particular index.
|
||
|
</summary>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHintCollection.IndexOf(Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint)">
|
||
|
<param name="value">The <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint" /> object for which to search.</param><summary>Gets the index of the specified <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint" /> object.</summary><returns>The zero-based index of the column order hint, or -1 if the column order hint is not found in the collection.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHintCollection.Insert(System.Int32,Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint)">
|
||
|
<param name="index">Integer value of the location within the <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHintCollection" /> at which to insert the new
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint" />.</param><param name="columnOrderHint">
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint" /> object to be inserted in the collection.</param><summary>Insert a new <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint" /> at the index specified.</summary><remarks>The order in which column order hints can be added is arbitrary.</remarks><exception cref="T:System.ArgumentOutOfRangeException">The index is less than zero or greater than the size of the collection.</exception><exception cref="T:System.ArgumentNullException">A null column order hint cannot be added to the collection.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHintCollection.Remove(Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint)">
|
||
|
<param name="columnOrderHint">
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint" /> object to be removed from the collection.</param><summary>Removes the specified <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint" /> element from the <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHintCollection" />.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The Remove method is most commonly used when you use a single <xref:Microsoft.Data.SqlClient.SqlBulkCopy>
|
||
|
instance to process more than one bulk copy operation. If you create column order hints for one bulk copy operation, you must clear the
|
||
|
<xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHintCollection> after the <xref:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer%2A> method and before processing the next bulk copy.
|
||
|
|
||
|
You can clear the entire collection by using the
|
||
|
<xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHintCollection.Clear> method, or remove hints individually using the Remove method or the <xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHintCollection.RemoveAt%2A> method.
|
||
|
|
||
|
Performing several bulk copies using the same <xref:Microsoft.Data.SqlClient.SqlBulkCopy> instance will usually be more efficient from a performance point of view than using a separate
|
||
|
<xref:Microsoft.Data.SqlClient.SqlBulkCopy> for each operation.
|
||
|
|
||
|
## Examples
|
||
|
The following example performs two bulk copy operations. The first operation copies sales order header information, and the second copies sales order details.
|
||
|
The example defines a column order hint for the **OrderDate** column in the first bulk copy operation. The hint is removed before the second bulk copy operation.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to use a
|
||
|
Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.ColumnOrderHintCollectionRemove#1](~/../sqlclient/doc/samples/SqlBulkCopy_ColumnOrderHintCollectionRemove.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">The value is null.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHintCollection.RemoveAt(System.Int32)">
|
||
|
<param name="index">The zero-based index of the <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHint" /> object to be removed from the collection.</param><summary>Removes the column order hint at the specified index from the collection.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHintCollection.RemoveAt> method is most commonly used when you use a single <xref:Microsoft.Data.SqlClient.SqlBulkCopy>
|
||
|
instance to process more than one bulk copy operation. If you create column order hints for one bulk copy operation, you must clear the
|
||
|
<xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHintCollection> after the <xref:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer> method and before processing the next bulk copy.
|
||
|
You can clear the entire collection by using the
|
||
|
<xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHintCollection.Clear> method, or remove hints individually using the <xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHintCollection.Remove>
|
||
|
method or the <xref:Microsoft.Data.SqlClient.SqlBulkCopyColumnOrderHintCollection.RemoveAt> method.
|
||
|
|
||
|
Performing several bulk copies using the same <xref:Microsoft.Data.SqlClient.SqlBulkCopy> instance will usually be more efficient from a performance point of view than using a separate
|
||
|
<xref:Microsoft.Data.SqlClient.SqlBulkCopy> for each operation.
|
||
|
|
||
|
## Examples
|
||
|
The following example performs two bulk copy operations. The first operation copies sales order header information, and the second copies sales order details.
|
||
|
The example defines a column order hint for the **OrderDate** column in the first bulk copy operation. The hint is removed before the second bulk copy operation.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance, it is easier and faster to use a
|
||
|
Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.ColumnOrderHintCollectionRemoveAt#1](~/../sqlclient/doc/samples/SqlBulkCopy_ColumnOrderHintCollectionRemoveAt.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentOutOfRangeException">The index must be non-negative and less than the size of the collection.</exception>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlBulkCopyOptions">
|
||
|
<summary>Bitwise flag that specifies one or more options to use with an instance of <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
You can use the <xref:Microsoft.Data.SqlClient.SqlBulkCopyOptions> enumeration when you construct a <xref:Microsoft.Data.SqlClient.SqlBulkCopy> instance to change how the
|
||
|
<xref:Microsoft.Data.SqlClient.SqlBulkCopy.WriteToServer%2A> methods for that instance behave.
|
||
|
|
||
|
## Examples
|
||
|
The following console application demonstrates how to perform a bulk load that copies the value in the identity column of the source table to the corresponding column in the destination table,
|
||
|
instead of generating a new value for each row's identity column.
|
||
|
|
||
|
To see how the option changes the way the bulk load works, run the sample with the **dbo.BulkCopyDemoMatchingColumns** table empty. All rows load from the source.
|
||
|
Next, run the sample again without emptying the table. An exception is thrown, and the code writes a message to the console window notifying you that rows were not added because of
|
||
|
primary key violations.
|
||
|
|
||
|
> [!IMPORTANT]
|
||
|
> This sample will not run unless you have created the work tables as described in [Bulk Copy Example Setup](/sql/connect/ado-net/sql/bulk-copy-example-setup).
|
||
|
This code is provided to demonstrate the syntax for using **SqlBulkCopy** only. If the source and destination tables are in the same SQL Server instance,
|
||
|
it is easier and faster to use a Transact-SQL `INSERT … SELECT` statement to copy the data.
|
||
|
|
||
|
[!code-csharp[SqlBulkCopy.KeepIdentity#1](~/../sqlclient/doc/samples/SqlBulkCopy_KeepIdentity.cs)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlBulkCopyOptions.AllowEncryptedValueModifications">
|
||
|
<summary>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
When specified, **AllowEncryptedValueModifications** enables bulk copying of encrypted data between tables or databases, without decrypting the data. Typically,
|
||
|
an application would select data from encrypted columns from one table without decrypting the data (the app would connect to the database with the column encryption setting keyword set
|
||
|
to disabled) and then would use this option to bulk insert the data, which is still encrypted.
|
||
|
|
||
|
Use caution when specifying **AllowEncryptedValueModifications** as this may lead to corrupting the database because the driver does not check if the data is indeed encrypted,
|
||
|
or if it is correctly encrypted using the same encryption type, algorithm and key as the target column.
|
||
|
]]></format>
|
||
|
</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints">
|
||
|
<summary>Check constraints while data is being inserted. By default, constraints are not checked.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlBulkCopyOptions.Default">
|
||
|
<summary>Use the default values for all options.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlBulkCopyOptions.FireTriggers">
|
||
|
<summary>When specified, cause the server to fire the insert triggers for the rows being inserted into the database.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlBulkCopyOptions.KeepIdentity">
|
||
|
<summary>Preserve source identity values. When not specified, identity values are assigned by the destination.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlBulkCopyOptions.KeepNulls">
|
||
|
<summary>Preserve null values in the destination table regardless of the settings for default values. When not specified, null values are replaced by default values where applicable.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlBulkCopyOptions.TableLock">
|
||
|
<summary>Obtain a bulk update lock for the duration of the bulk copy operation. When not specified, row locks are used.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlBulkCopyOptions.UseInternalTransaction">
|
||
|
<summary>When specified, each batch of the bulk-copy operation will occur within a transaction. If you indicate this option and also provide a <see cref="T:Microsoft.Data.SqlClient.SqlTransaction" />
|
||
|
object to the constructor, an <see cref="T:System.ArgumentException" /> occurs.
|
||
|
</summary>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlClientFactory">
|
||
|
<summary>
|
||
|
Represents a set of methods for creating instances of the
|
||
|
<see cref="N:Microsoft.Data.SqlClient" />
|
||
|
provider's implementation of the data source classes.
|
||
|
</summary><remarks>
|
||
|
To be added.
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlClientFactory.Instance">
|
||
|
<summary>
|
||
|
Gets an instance of the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlClientFactory" />
|
||
|
. This can be used to retrieve strongly typed data objects.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Examples
|
||
|
The following code fragment uses the <xref:Microsoft.Data.SqlClient.SqlClientFactory.Instance> property to retrieve a **SqlClientFactory** instance, and then return a strongly typed
|
||
|
<xref:System.Data.Common.DbCommand> instance:
|
||
|
|
||
|
|
||
|
```csharp
|
||
|
SqlClientFactory newFactory = SqlClientFactory.Instance;
|
||
|
DbCommand cmd = newFactory.CreateCommand();
|
||
|
```
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlClientFactory.CreateCommand">
|
||
|
<summary>
|
||
|
Returns a strongly typed
|
||
|
<see cref="T:System.Data.Common.DbCommand" />
|
||
|
instance.
|
||
|
</summary><returns>
|
||
|
A new strongly typed instance of
|
||
|
<see cref="T:System.Data.Common.DbCommand" />
|
||
|
.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Examples
|
||
|
The following code fragment returns a strongly typed <xref:System.Data.Common.DbCommand> instance:
|
||
|
|
||
|
|
||
|
```csharp
|
||
|
SqlClientFactory newFactory = SqlClientFactory.Instance;
|
||
|
DbCommand cmd = newFactory.CreateCommand();
|
||
|
```
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlClientFactory.CreateCommandBuilder">
|
||
|
<summary>
|
||
|
Returns a strongly typed
|
||
|
<see cref="T:System.Data.Common.DbCommandBuilder" />
|
||
|
instance.
|
||
|
</summary><returns>
|
||
|
A new strongly typed instance of
|
||
|
<see cref="T:System.Data.Common.DbCommandBuilder" />
|
||
|
.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Examples
|
||
|
The following code fragment returns a strongly typed <xref:System.Data.Common.DbCommandBuilder> instance:
|
||
|
|
||
|
|
||
|
```csharp
|
||
|
SqlClientFactory newFactory = SqlClientFactory.Instance;
|
||
|
DbCommandBuilder cmd = newFactory.CreateCommandBuilder();
|
||
|
```
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlClientFactory.CreateConnection">
|
||
|
<summary>
|
||
|
Returns a strongly typed
|
||
|
<see cref="T:System.Data.Common.DbConnection" />
|
||
|
instance.
|
||
|
</summary><returns>
|
||
|
A new strongly typed instance of
|
||
|
<see cref="T:System.Data.Common.DbConnection" />
|
||
|
.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Examples
|
||
|
The following code fragment returns a strongly typed <xref:System.Data.Common.DbConnection> instance:
|
||
|
|
||
|
|
||
|
```csharp
|
||
|
SqlClientFactory newFactory = SqlClientFactory.Instance;
|
||
|
DbConnection cmd = newFactory.CreateConnection();
|
||
|
|
||
|
```
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlClientFactory.CreateConnectionStringBuilder">
|
||
|
<summary>
|
||
|
Returns a strongly typed
|
||
|
<see cref="T:System.Data.Common.DbConnectionStringBuilder" />
|
||
|
instance.
|
||
|
</summary><returns>
|
||
|
A new strongly typed instance of
|
||
|
<see cref="T:System.Data.Common.DbConnectionStringBuilder" />
|
||
|
.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Examples
|
||
|
The following code fragment returns a strongly typed <xref:System.Data.Common.DbConnectionStringBuilder> instance:
|
||
|
|
||
|
```csharp
|
||
|
SqlClientFactory newFactory = SqlClientFactory.Instance;
|
||
|
DbConnectionStringBuilder cmd =
|
||
|
newFactory.CreateConnectionStringBuilder();
|
||
|
```
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlClientFactory.CreateDataAdapter">
|
||
|
<summary>
|
||
|
Returns a strongly typed
|
||
|
<see cref="T:System.Data.Common.DbDataAdapter" />
|
||
|
instance.
|
||
|
</summary><returns>
|
||
|
A new strongly typed instance of
|
||
|
<see cref="T:System.Data.Common.DbDataAdapter" />
|
||
|
.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Examples
|
||
|
The following code fragment returns a strongly typed <xref:System.Data.Common.DbDataAdapter> instance:
|
||
|
|
||
|
```csharp
|
||
|
SqlClientFactory newFactory = SqlClientFactory.Instance;
|
||
|
DbDataAdapter cmd = newFactory.CreateDataAdapter();
|
||
|
```
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlClientFactory.CreateParameter">
|
||
|
<summary>
|
||
|
Returns a strongly typed
|
||
|
<see cref="T:System.Data.Common.DbParameter" />
|
||
|
instance.
|
||
|
</summary><returns>
|
||
|
A new strongly typed instance of
|
||
|
<see cref="T:System.Data.Common.DbParameter" />
|
||
|
.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Examples
|
||
|
The following code fragment returns a strongly typed <xref:System.Data.Common.DbParameter> instance:
|
||
|
|
||
|
|
||
|
```csharp
|
||
|
SqlClientFactory newFactory = SqlClientFactory.Instance;
|
||
|
DbParameter cmd = newFactory.CreateParameter();
|
||
|
```
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlClientLogger">
|
||
|
<summary>Represents a SQL client logger.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlClientLogger.#ctor">
|
||
|
<summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.SqlClientLogger" /> class.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlClientLogger.IsLoggingEnabled">
|
||
|
<summary>Gets a value that indicates whether bid tracing is enabled.</summary><value>
|
||
|
<see langword="true" /> if bid tracing is enabled; otherwise, <see langword="false" />.</value><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlClientLogger.LogWarning(System.String,System.String,System.String)">
|
||
|
<param name="type">The type to be logged.</param><param name="method">The logging method.</param><param name="message">The message to be logged.</param><summary>Logs warning through a specified method of the current instance type.</summary>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlClientLogger.LogAssert(System.Boolean,System.String,System.String,System.String)">
|
||
|
<param name="value"><see langword="false" /> to log the message; otherwise, <see langword="true" />.</param><param name="type">The type to be logged.</param><param name="method">The logging method.</param><param name="message">The message to be logged.</param><summary>Logs the specified message if <paramref name="value" /> is <see langword="false" />.</summary><returns><see langword="true" /> if the message is not logged; otherwise, <see langword="false" />.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlClientLogger.LogError(System.String,System.String,System.String)">
|
||
|
<param name="type">The type to be logged.</param><param name="method">The logging method.</param><param name="message">The message to be logged.</param><summary>Logs an error through a specified method of the current instance type.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlClientLogger.LogInfo(System.String,System.String,System.String)">
|
||
|
<param name="type">The type to be logged.</param><param name="method">The logging method.</param><param name="message">The message to be logged.</param><summary>Logs information through a specified method of the current instance type.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlClientMetaDataCollectionNames">
|
||
|
<summary>Provides a list of constants for use with the **GetSchema** method to retrieve metadata collections.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlClientMetaDataCollectionNames.Columns">
|
||
|
<summary>A constant for use with the **GetSchema** method that represents the **Columns** collection.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlClientMetaDataCollectionNames.Databases">
|
||
|
<summary>A constant for use with the **GetSchema** method that represents the **Databases** collection.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlClientMetaDataCollectionNames.ForeignKeys">
|
||
|
<summary>A constant for use with the **GetSchema** method that represents the **ForeignKeys** collection.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlClientMetaDataCollectionNames.IndexColumns">
|
||
|
<summary>A constant for use with the **GetSchema** method that represents the **IndexColumns** collection.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlClientMetaDataCollectionNames.Indexes">
|
||
|
<summary>A constant for use with the **GetSchema** method that represents the **Indexes** collection.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlClientMetaDataCollectionNames.ProcedureParameters">
|
||
|
<summary>A constant for use with the **GetSchema** method that represents the **ProcedureParameters** collection.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlClientMetaDataCollectionNames.Procedures">
|
||
|
<summary>A constant for use with the **GetSchema** method that represents the **Procedures** collection.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlClientMetaDataCollectionNames.Tables">
|
||
|
<summary>A constant for use with the **GetSchema** method that represents the **Tables** collection.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlClientMetaDataCollectionNames.UserDefinedTypes">
|
||
|
<summary>A constant for use with the **GetSchema** method that represents the **UserDefinedTypes** collection.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlClientMetaDataCollectionNames.Users">
|
||
|
<summary>A constant for use with the **GetSchema** method that represents the **Users** collection.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlClientMetaDataCollectionNames.ViewColumns">
|
||
|
<summary>A constant for use with the **GetSchema** method that represents the **ViewColumns** collection.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlClientMetaDataCollectionNames.Views">
|
||
|
<summary>A constant for use with the **GetSchema** method that represents the **Views** collection.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlClientMetaDataCollectionNames.AllColumns">
|
||
|
<summary>A constant for use with the **GetSchema** method that represents the **AllColumns** collection.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlClientMetaDataCollectionNames.ColumnSetColumns">
|
||
|
<summary>A constant for use with the **GetSchema** method that represents the **ColumnSetColumns** collection.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlClientMetaDataCollectionNames.StructuredTypeMembers">
|
||
|
<summary>A constant for use with the **GetSchema** method that represents the **StructuredTypeMembers** collection.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlConnectionAttestationProtocol">
|
||
|
<summary>
|
||
|
Specifies a value for Attestation Protocol.
|
||
|
</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlConnectionAttestationProtocol.NotSpecified">
|
||
|
<summary>If the attestation protocol is not specified. Use this as default value.</summary><value>0</value>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlConnectionAttestationProtocol.AAS">
|
||
|
<summary>Attestation portocol for Azure Attestation Service</summary><value>1</value>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlConnectionAttestationProtocol.None">
|
||
|
<summary>Attestation protocol for no attestation. Only compatible with Virtualization-based security (VBS) enclaves. An Enclave Attestation Url is not required when using this protocol.</summary><value>2</value>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlConnectionAttestationProtocol.HGS">
|
||
|
<summary>Attestation protocol for Host Guardian Service</summary><value>3</value>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlConnectionIPAddressPreference">
|
||
|
<summary>
|
||
|
Specifies a value for IP address preference during a TCP connection.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
If `Multi Subnet Failover` is set to `true`, this setting has no effect.
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlConnectionIPAddressPreference.IPv4First">
|
||
|
<summary>Connects using IPv4 address(es) first. If the connection fails, try IPv6 address(es), if provided. This is the default value.</summary><value>0</value>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlConnectionIPAddressPreference.IPv6First">
|
||
|
<summary>Connect using IPv6 address(es) first. If the connection fails, try IPv4 address(es), if available.</summary><value>1</value>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlConnectionIPAddressPreference.UsePlatformDefault">
|
||
|
<summary>Connects with IP addresses in the order the underlying platform or operating system provides them.</summary><value>2</value>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlConnectionEncryptOption">
|
||
|
<summary>These options are used to control encryption behavior of the communication between the server and the client.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Implicit conversions have been added to maintain backwards compatibility with boolean behahavior for the <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.Encrypt%2A> property. When converting from a boolean, a value of `true` converts to <xref:Microsoft.Data.SqlClient.SqlConnectionEncryptOption.Mandatory%2A> and a value of `false` converts to <xref:Microsoft.Data.SqlClient.SqlConnectionEncryptOption.Optional%2A>. When converting to a boolean, <xref:Microsoft.Data.SqlClient.SqlConnectionEncryptOption.Mandatory%2A>, <xref:Microsoft.Data.SqlClient.SqlConnectionEncryptOption.Strict%2A> , and `null` convert to `true` and <xref:Microsoft.Data.SqlClient.SqlConnectionEncryptOption.Optional%2A> converts `false`.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnectionEncryptOption.Parse(System.String)">
|
||
|
<summary>
|
||
|
Converts the specified string representation of a logical value to its <see cref="T:Microsoft.Data.SqlClient.SqlConnectionEncryptOption" /> equivalent.
|
||
|
</summary><param name="value">A string containing the value to convert.</param><returns>
|
||
|
An object that is equivalent to <see cref="T:Microsoft.Data.SqlClient.SqlConnectionEncryptOption" /> contained in <paramref name="value" />.
|
||
|
</returns><exception cref="T:System.ArgumentException">
|
||
|
Throws exception if provided <paramref name="value" /> is not convertible to <see cref="T:Microsoft.Data.SqlClient.SqlConnectionEncryptOption" /> type.
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnectionEncryptOption.TryParse(System.String,Microsoft.Data.SqlClient.SqlConnectionEncryptOption@)">
|
||
|
<summary>
|
||
|
Converts the specified string representation of a logical value to its <see cref="T:Microsoft.Data.SqlClient.SqlConnectionEncryptOption" /> equivalent and returns a value that indicates whether the conversion succeeded.
|
||
|
</summary><param name="value">A string containing the value to convert.</param><param name="result">
|
||
|
An object that is equivalent to <see cref="T:Microsoft.Data.SqlClient.SqlConnectionEncryptOption" /> contained in <paramref name="value" />. <see langword="null" /> if conversion fails.
|
||
|
</param><returns>
|
||
|
<see langword="true" /> if the <paramref name="value" /> parameter was converted successfully; otherwise, <see langword="false" />.
|
||
|
</returns><remarks>This method does not throw an exception if conversion fails.</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionEncryptOption.Optional">
|
||
|
<summary>Specifies that TLS encryption is optional when connecting to the server. If the server requires encryption, encryption will be negotiated.</summary>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionEncryptOption.Mandatory">
|
||
|
<summary>Specifies that TLS encryption is required when connecting to the server. If the server doesn't support encryption, the connection will fail.</summary>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionEncryptOption.Strict">
|
||
|
<summary>Enables and requires TDS 8.0, TLS encryption to the server. If the server doesn't support TDS 8.0, TLS encryption, the connection will fail.</summary>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnectionEncryptOption.op_Implicit(System.Boolean)~Microsoft.Data.SqlClient.SqlConnectionEncryptOption">
|
||
|
<param name="value">The boolean value to be used for implicit comparison.</param><summary>
|
||
|
Enables implicit converstion of a boolean to a <see cref="T:Microsoft.Data.SqlClient.SqlConnectionEncryptOption" />. A value of <see langword="true" /> converts to <see cref="P:Microsoft.Data.SqlClient.SqlConnectionEncryptOption.Mandatory" />. A value of <see langword="false" /> converts to <see cref="P:Microsoft.Data.SqlClient.SqlConnectionEncryptOption.Optional" />.
|
||
|
</summary>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnectionEncryptOption.op_Implicit(Microsoft.Data.SqlClient.SqlConnectionEncryptOption)~System.Boolean">
|
||
|
<param name="value">The <see cref="T:Microsoft.Data.SqlClient.SqlConnectionEncryptOption" /> value to be used for implicit comparison.</param><summary>
|
||
|
Enables implicit converstion of a <see cref="T:Microsoft.Data.SqlClient.SqlConnectionEncryptOption" /> to a boolean. <see cref="P:Microsoft.Data.SqlClient.SqlConnectionEncryptOption.Mandatory" /> and <see cref="P:Microsoft.Data.SqlClient.SqlConnectionEncryptOption.Strict" /> convert to <see langword="true" />. <see cref="P:Microsoft.Data.SqlClient.SqlConnectionEncryptOption.Optional" /> converts to <see langword="false" />.
|
||
|
</summary>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnectionEncryptOption.ToString">
|
||
|
<summary>Returns the string value of <see cref="T:Microsoft.Data.SqlClient.SqlConnectionEncryptOption" />.</summary>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnectionEncryptOption.Equals(System.Object)">
|
||
|
<summary>
|
||
|
Compares the <see cref="M:Microsoft.Data.SqlClient.SqlConnectionEncryptOption.ToString" /> representation of <see cref="T:Microsoft.Data.SqlClient.SqlConnectionEncryptOption" /> to another <see cref="T:Microsoft.Data.SqlClient.SqlConnectionEncryptOption" />.
|
||
|
</summary>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnectionEncryptOption.GetHashCode">
|
||
|
<summary>
|
||
|
Returns the hash code of the <see cref="M:Microsoft.Data.SqlClient.SqlConnectionEncryptOption.ToString" /> value.
|
||
|
</summary>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlColumnEncryptionCertificateStoreProvider">
|
||
|
<summary>The implementation of the key store provider for Windows Certificate Store. This class enables using certificates stored in the Windows Certificate Store as column master keys.
|
||
|
For details, see <see href="https://docs.microsoft.com/sql/relational-databases/security/encryption/always-encrypted-database-engine">Always Encrypted</see>.
|
||
|
</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlColumnEncryptionCertificateStoreProvider.ProviderName">
|
||
|
<summary>The provider name.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlColumnEncryptionCertificateStoreProvider.#ctor">
|
||
|
<summary>Key store provider for Windows Certificate Store.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlColumnEncryptionCertificateStoreProvider.DecryptColumnEncryptionKey(System.String,System.String,System.Byte[])">
|
||
|
<param name="masterKeyPath">The master key path.</param><param name="encryptionAlgorithm">The encryption algorithm. Currently, the only valid value is: <c>RSA_OAEP</c>
|
||
|
</param><param name="encryptedColumnEncryptionKey">The encrypted column encryption key.</param><summary>Decrypts the specified encrypted value of a column encryption key. The encrypted value is expected to be encrypted using the certificate with the specified key path and using the specified
|
||
|
algorithm. The format of the key path should be "Local Machine/My/<certificate_thumbprint>" or "Current User/My/<certificate_thumbprint>".
|
||
|
</summary><returns>Returns <see cref="T:System.Byte" />
|
||
|
. The decrypted column encryption key.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlColumnEncryptionCertificateStoreProvider.EncryptColumnEncryptionKey(System.String,System.String,System.Byte[])">
|
||
|
<param name="masterKeyPath">The master key path.</param><param name="encryptionAlgorithm">The encryption algorithm. Currently, the only valid value is: <c>RSA_OAEP</c>
|
||
|
</param><param name="columnEncryptionKey">The plaintext column encryption key.</param><summary>Encrypts a column encryption key using the certificate with the specified key path and using the specified algorithm. The format of the key path should be
|
||
|
"Local Machine/My/<certificate_thumbprint>" or "Current User/My/<certificate_thumbprint>".
|
||
|
</summary><returns>Returns <see cref="T:System.Byte" />
|
||
|
. The encrypted column encryption key.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlColumnEncryptionCertificateStoreProvider.SignColumnMasterKeyMetadata(System.String,System.Boolean)">
|
||
|
<param name="masterKeyPath">The column master key path.</param><param name="allowEnclaveComputations">
|
||
|
<see langword="true" />
|
||
|
to indicate that the column master key supports enclave computations; otherwise, <see langword="false" />
|
||
|
.</param><summary>Digitally signs the column master key metadata with the column master key referenced by the <paramref name="masterKeyPath" />
|
||
|
parameter.</summary><returns>The signature of the column master key metadata.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlColumnEncryptionCertificateStoreProvider.VerifyColumnMasterKeyMetadata(System.String,System.Boolean,System.Byte[])">
|
||
|
<param name="masterKeyPath">The complete path of an asymmetric key. The path format is specific to a key store provider.</param><param name="allowEnclaveComputations">A Boolean that indicates if this key can be sent to the trusted enclave.</param><param name="signature">The master key metadata siognature.</param><summary>This function must be implemented by the corresponding Key Store providers. This function should use an asymmetric key identified by a key path and verify the masterkey metadata consisting of (masterKeyPath, allowEnclaveComputations, providerName).</summary><returns>A Boolean value that indicates if the master key metadata can be verified based on the provided signature.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlColumnEncryptionCngProvider">
|
||
|
<summary>The CMK Store provider implementation for using the Microsoft Cryptography API: Next Generation (CNG) with
|
||
|
<see href="https://docs.microsoft.com/sql/relational-databases/security/encryption/always-encrypted-database-engine">Always Encrypted</see>.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Enables storing Always Encrypted column master key keys in a store, such as a hardware security module (HSM), that supports the Microsoft Cryptography API: Next Generation (CNG).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlColumnEncryptionCngProvider.ProviderName">
|
||
|
<summary>A constant string for the provider name 'MSSQL_CNG_STORE'.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlColumnEncryptionCngProvider.#ctor">
|
||
|
<summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.SqlColumnEncryptionCngProvider" /> class.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlColumnEncryptionCngProvider.DecryptColumnEncryptionKey(System.String,System.String,System.Byte[])">
|
||
|
<param name="masterKeyPath">The master key path.</param><param name="encryptionAlgorithm">The encryption algorithm.</param><param name="encryptedColumnEncryptionKey">The encrypted column encryption key.</param><summary>Decrypts the given encrypted value using an asymmetric key specified by the key path and the specified algorithm. The key path will be in the format of [ProviderName]/KeyIdentifier
|
||
|
and should be an asymmetric key stored in the specified CNG key store provider. The valid algorithm used to encrypt/decrypt the CEK is 'RSA_OAEP'.
|
||
|
</summary><returns>The decrypted column encryption key.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlColumnEncryptionCngProvider.EncryptColumnEncryptionKey(System.String,System.String,System.Byte[])">
|
||
|
<param name="masterKeyPath">The master key path.</param><param name="encryptionAlgorithm">The encryption algorithm.</param><param name="columnEncryptionKey">The plaintext column encryption key.</param><summary>Encrypts the given plain text column encryption key using an asymmetric key specified by the key path and the specified algorithm. The key path will be in the format of [ProviderName]/KeyIdentifier and should be an asymmetric key stored in the specified CNG key store provider. The valid algorithm used to encrypt/decrypt the CEK is 'RSA_OAEP'.</summary><returns>The encrypted column encryption key.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlColumnEncryptionCngProvider.SignColumnMasterKeyMetadata(System.String,System.Boolean)">
|
||
|
<param name="masterKeyPath">The column master key path. The path format is specific to a key store provider.</param><param name="allowEnclaveComputations"><see langword="true" /> to indicate that the column master key supports enclave computations; otherwise, <see langword="false" />.</param><summary>Throws a <see cref="T:System.NotSupportedException" /> exception in all cases.</summary><returns>The signature of the column master key metadata.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlColumnEncryptionCngProvider.SignColumnMasterKeyMetadata%2A> method must be implemented by the corresponding key store providers.
|
||
|
<xref:Microsoft.Data.SqlClient.SqlColumnEncryptionCngProvider.SignColumnMasterKeyMetadata%2A> should use an asymmetric key identified by a key path and sign the masterkey metadata consisting
|
||
|
of `masterKeyPath`, `allowEnclaveComputations`, and providerName.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlColumnEncryptionCngProvider.VerifyColumnMasterKeyMetadata(System.String,System.Boolean,System.Byte[])">
|
||
|
<param name="masterKeyPath">The complete path of an asymmetric key. The path format is specific to a key store provider.</param><param name="allowEnclaveComputations">A Boolean that indicates if this key can be sent to the trusted enclave.</param><param name="signature">The master key metadata signature.</param><summary>This function must be implemented by the corresponding Key Store providers. This function should use an asymmetric key identified by a key path and verify the masterkey metadata consisting of (masterKeyPath, allowEnclaveComputations, providerName).</summary><returns>A Boolean that indicates if the master key metadata can be verified based on the provided signature.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlColumnEncryptionCspProvider">
|
||
|
<summary>The CMK Store provider implementation for using Microsoft CAPI based Cryptographic Service Providers (CSP) with
|
||
|
<see href="https://docs.microsoft.com/sql/relational-databases/security/encryption/always-encrypted-database-engine">Always Encrypted</see>.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Enables storing Always Encrypted column master key keys in a store, such as a hardware security module (HSM), that supports the Microsoft CAPI based Cryptographic Service Providers (CSP).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlColumnEncryptionCspProvider.ProviderName">
|
||
|
<summary>A constant string for the provider name 'MSSQL_CSP_PROVIDER'.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlColumnEncryptionCspProvider.#ctor">
|
||
|
<summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.SqlColumnEncryptionCspProvider" /> class.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlColumnEncryptionCspProvider.DecryptColumnEncryptionKey(System.String,System.String,System.Byte[])">
|
||
|
<param name="masterKeyPath">The master key path.</param><param name="encryptionAlgorithm">The encryption algorithm.</param><param name="encryptedColumnEncryptionKey">The encrypted column encryption key.</param><summary>Decrypts the given encrypted value using an asymmetric key specified by the key path and algorithm. The key path will be in the format of [ProviderName]/KeyIdentifier and should be an asymmetric key stored in the specified CSP provider. The valid algorithm used to encrypt/decrypt the CEK is 'RSA_OAEP'.</summary><returns>The decrypted column encryption key.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlColumnEncryptionCspProvider.EncryptColumnEncryptionKey(System.String,System.String,System.Byte[])">
|
||
|
<param name="masterKeyPath">The master key path.</param><param name="encryptionAlgorithm">The encryption algorithm.</param><param name="columnEncryptionKey">The plaintext column encryption key.</param><summary>Encrypts the given plain text column encryption key using an asymmetric key specified by the key path and the specified algorithm. The key path will be in the format of [ProviderName]/KeyIdentifier and should be an asymmetric key stored in the specified CSP provider. The valid algorithm used to encrypt/decrypt the CEK is 'RSA_OAEP'.</summary><returns>The encrypted column encryption key.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlColumnEncryptionCspProvider.SignColumnMasterKeyMetadata(System.String,System.Boolean)">
|
||
|
<param name="masterKeyPath">The column master key path. The path format is specific to a key store provider.</param><param name="allowEnclaveComputations"><see langword="true" /> to indicate that the column master key supports enclave computations; otherwise, <see langword="false" />.</param><summary>Throws a <see cref="T:System.NotSupportedException" /> exception in all cases.</summary><returns>The signature of the column master key metadata.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlColumnEncryptionCspProvider.SignColumnMasterKeyMetadata%2A> method must be implemented by the corresponding key store providers.
|
||
|
<xref:Microsoft.Data.SqlClient.SqlColumnEncryptionCspProvider.SignColumnMasterKeyMetadata%2A> should use an asymmetric key identified by a key path and sign the masterkey metadata
|
||
|
consisting of `masterKeyPath`, `allowEnclaveComputations`, and providerName.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlColumnEncryptionCspProvider.VerifyColumnMasterKeyMetadata(System.String,System.Boolean,System.Byte[])">
|
||
|
<param name="masterKeyPath">The complete path of an asymmetric key. The path format is specific to a key store provider.</param><param name="allowEnclaveComputations">A boolean that indicates if this key can be sent to the trusted enclave.</param><param name="signature">Master key metadata signature.</param><summary>This function must be implemented by the corresponding Key Store providers. This function should use an asymmetric key identified by a key path and sign the masterkey metadata consisting of (masterKeyPath, allowEnclaveComputations, providerName).</summary><returns>A Boolean that indicates if the master key metadata can be verified based on the provided signature.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlColumnEncryptionKeyStoreProvider">
|
||
|
<summary>Base class for all key store providers. A custom provider must derive from this class and override its member functions and then register it using
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlConnection.RegisterColumnEncryptionKeyStoreProviders(System.Collections.Generic.IDictionary{System.String,Microsoft.Data.SqlClient.SqlColumnEncryptionKeyStoreProvider})" />,
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlConnection.RegisterColumnEncryptionKeyStoreProvidersOnConnection(System.Collections.Generic.IDictionary{System.String,Microsoft.Data.SqlClient.SqlColumnEncryptionKeyStoreProvider})" /> or
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.RegisterColumnEncryptionKeyStoreProvidersOnCommand(System.Collections.Generic.IDictionary{System.String,Microsoft.Data.SqlClient.SqlColumnEncryptionKeyStoreProvider})" />.
|
||
|
For details see, <see href="https://docs.microsoft.com/sql/relational-databases/security/encryption/always-encrypted-database-engine"> Always Encrypted</see>.
|
||
|
</summary>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlColumnEncryptionKeyStoreProvider.#ctor">
|
||
|
<summary>Initializes a new instance of the SqlColumnEncryptionKeyStoreProviderClass.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlColumnEncryptionKeyStoreProvider.DecryptColumnEncryptionKey(System.String,System.String,System.Byte[])">
|
||
|
<param name="masterKeyPath">The master key path.</param><param name="encryptionAlgorithm">The encryption algorithm.</param><param name="encryptedColumnEncryptionKey">The encrypted column encryption key.</param><summary>Decrypts the specified encrypted value of a column encryption key. The encrypted value is expected to be encrypted using the column master key with the specified key path and using the specified algorithm.
|
||
|
</summary><returns>Returns <see cref="T:System.Byte" />. The decrypted column encryption key.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlColumnEncryptionKeyStoreProvider.EncryptColumnEncryptionKey(System.String,System.String,System.Byte[])">
|
||
|
<param name="masterKeyPath">The master key path.</param><param name="encryptionAlgorithm">The encryption algorithm.</param><param name="columnEncryptionKey">The plaintext column encryption key.</param><summary>Encrypts a column encryption key using the column master key with the specified key path and using the specified algorithm.</summary><returns>Returns <see cref="T:System.Byte" />. The encrypted column encryption key.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlColumnEncryptionKeyStoreProvider.SignColumnMasterKeyMetadata(System.String,System.Boolean)">
|
||
|
<param name="masterKeyPath">The column master key path.</param><param name="allowEnclaveComputations"><see langword="true" /> to indicate that the column master key supports enclave computations; otherwise, <see langword="false" />.</param><summary>When implemented in a derived class, digitally signs the column master key metadata with the column master key referenced by the <paramref name="masterKeyPath" /> parameter. The input values used to generate the signature should be the specified values of the <paramref name="masterKeyPath" /> and <paramref name="allowEnclaveComputations" /> parameters.
|
||
|
</summary><returns>The signature of the column master key metadata.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
To ensure that the <xref:Microsoft.Data.SqlClient.SqlColumnEncryptionKeyStoreProvider.SignColumnMasterKeyMetadata%2A> method doesn't break applications that rely on an old API, it throws a
|
||
|
<xref:System.NotImplementedException> exception by default.
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlColumnEncryptionKeyStoreProvider.SignColumnMasterKeyMetadata%2A> method will be used by client tools that generate Column Master Keys (CMK) for customers.
|
||
|
<xref:Microsoft.Data.SqlClient.SqlColumnEncryptionKeyStoreProvider.SignColumnMasterKeyMetadata%2A> must be implemented by the corresponding key store providers that wish to use enclaves with
|
||
|
[Always Encrypted](https://docs.microsoft.com/sql/relational-databases/security/encryption/always-encrypted-database-engine).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.NotImplementedException">In all cases.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlColumnEncryptionKeyStoreProvider.VerifyColumnMasterKeyMetadata(System.String,System.Boolean,System.Byte[])">
|
||
|
<param name="masterKeyPath">The column master key path.</param><param name="allowEnclaveComputations">Indicates whether the column master key supports enclave computations.</param><param name="signature">The signature of the column master key metadata.</param><summary>When implemented in a derived class, this method is expected to verify the specified signature is valid for the column master key with the specified key path and the specified enclave behavior. The default implementation throws NotImplementedException.</summary><returns>When implemented in a derived class, the method is expected to return true if the specified signature is valid, or false if the specified signature is not valid. The default implementation throws NotImplementedException.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlColumnEncryptionKeyStoreProvider.ColumnEncryptionKeyCacheTtl">
|
||
|
<summary>Gets or sets the lifespan of the decrypted column encryption key in the cache. Once the timespan has elapsed, the decrypted column encryption key is discarded and must be revalidated.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
Internally, there is a cache of column encryption keys (once they are decrypted). This is useful for rapidly decrypting multiple data values. The default value is 2 hours. Setting this value to zero disables caching.
|
||
|
|
||
|
The column encryption keys decrypted by custom key store providers registered on a connection or command instance will not be cached. Custom key store providers should implement their own caching mechanism.
|
||
|
|
||
|
Caching implemented by custom key store providers will be disabled by the driver if the key store provider instance is registered using <xref:Microsoft.Data.SqlClient.SqlConnection.RegisterColumnEncryptionKeyStoreProviders(System.Collections.Generic.IDictionary{System.String,Microsoft.Data.SqlClient.SqlColumnEncryptionKeyStoreProvider})>. Any caching implementation should reference the value of this property before caching a column encryption key and not cache it if the value is zero. This will avoid duplicate caching and possible user confusion when they are trying to configure key caching.
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlCommandColumnEncryptionSetting">
|
||
|
<summary>Note that these settings cannot be used to bypass encryption and gain access to plaintext data. For details, see <see href="https://docs.microsoft.com/sql/relational-databases/security/encryption/always-encrypted-database-engine">Always Encrypted (Database Engine)</see>.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
- If Always Encrypted is disabled for a query and the query has parameters that need to be encrypted (parameters that correspond to encrypted columns), the query will fail.
|
||
|
- If Always Encrypted is disabled for a query and the query returns results from encrypted columns, the query will return encrypted values. The encrypted values will have the varbinary datatype.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlCommandColumnEncryptionSetting.Disabled">
|
||
|
<summary>Specifies the connection does not use Always Encrypted. Should be used if no queries sent over the connection access encrypted columns.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlCommandColumnEncryptionSetting.Enabled">
|
||
|
<summary>Enables Always Encrypted for the query.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlCommandColumnEncryptionSetting.ResultSetOnly">
|
||
|
<summary>Specifies that only the results of the command should be processed by the Always Encrypted routine in the driver. Use this value when the command has no parameters that require encryption.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlCommandColumnEncryptionSetting.UseConnectionSetting">
|
||
|
<summary>Specifies that the command should default to the Always Encrypted setting in the connection string.</summary>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlCommand">
|
||
|
<summary>
|
||
|
Represents a Transact-SQL statement or stored procedure to execute against a SQL Server database. This class cannot be inherited.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
When an instance of <xref:Microsoft.Data.SqlClient.SqlCommand> is created, the read/write properties are set to their initial values. For a list of these values, see the <xref:Microsoft.Data.SqlClient.SqlCommand> constructor.
|
||
|
|
||
|
<xref:Microsoft.Data.SqlClient.SqlCommand> features the following methods for executing commands at a SQL Server database:
|
||
|
|
||
|
|Item|Description|
|
||
|
|----------|-----------------|
|
||
|
|<xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteNonQuery%2A>|Initiates the asynchronous execution of the Transact-SQL statement or stored procedure that is described by this <xref:Microsoft.Data.SqlClient.SqlCommand>, generally executing commands such as INSERT, DELETE, UPDATE, and SET statements. Each call to <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteNonQuery%2A> must be paired with a call to <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteNonQuery%2A> which finishes the operation, typically on a separate thread.|
|
||
|
|<xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReader%2A>|Initiates the asynchronous execution of the Transact-SQL statement or stored procedure that is described by this <xref:Microsoft.Data.SqlClient.SqlCommand> and retrieves one or more results sets from the server. Each call to <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReader%2A> must be paired with a call to <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteReader%2A> which finishes the operation, typically on a separate thread.|
|
||
|
|<xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteXmlReader%2A>|Initiates the asynchronous execution of the Transact-SQL statement or stored procedure that is described by this <xref:Microsoft.Data.SqlClient.SqlCommand>. Each call to `BeginExecuteXmlReader` must be paired with a call to `EndExecuteXmlReader`, which finishes the operation, typically on a separate thread, and returns an <xref:System.Xml.XmlReader> object.|
|
||
|
|<xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteReader%2A>|Executes commands that return rows. For increased performance, <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteReader%2A> invokes commands using the Transact-SQL `sp_executesql` system stored procedure. Therefore, <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteReader%2A> might not have the effect that you want if used to execute commands such as Transact-SQL SET statements.|
|
||
|
|<xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteNonQuery%2A>|Executes commands such as Transact-SQL INSERT, DELETE, UPDATE, and SET statements.|
|
||
|
|<xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteScalar%2A>|Retrieves a single value (for example, an aggregate value) from a database.|
|
||
|
|<xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteXmlReader%2A>|Sends the <xref:Microsoft.Data.SqlClient.SqlCommand.CommandText%2A> to the <xref:Microsoft.Data.SqlClient.SqlCommand.Connection%2A> and builds an <xref:System.Xml.XmlReader> object.|
|
||
|
|
||
|
You can reset the <xref:Microsoft.Data.SqlClient.SqlCommand.CommandText%2A> property and reuse the <xref:Microsoft.Data.SqlClient.SqlCommand> object. However, you must close the <xref:Microsoft.Data.SqlClient.SqlDataReader> before you can execute a new or previous command.
|
||
|
|
||
|
If a <xref:Microsoft.Data.SqlClient.SqlException> is generated by the method executing a <xref:Microsoft.Data.SqlClient.SqlCommand>, the <xref:Microsoft.Data.SqlClient.SqlConnection> remains open when the severity level is 19 or less. When the severity level is 20 or greater, the server ordinarily closes the <xref:Microsoft.Data.SqlClient.SqlConnection>. However, the user can reopen the connection and continue.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> Nameless, also called ordinal, parameters are not supported by the .NET Framework Data Provider for SQL Server.
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlConnection>, a <xref:Microsoft.Data.SqlClient.SqlCommand>, and a <xref:Microsoft.Data.SqlClient.SqlDataReader>. The example reads through the data, writing it to the console. Finally, the example closes the <xref:Microsoft.Data.SqlClient.SqlDataReader> and then the <xref:Microsoft.Data.SqlClient.SqlConnection> as it exits the `Using` code blocks.
|
||
|
|
||
|
[!code-csharp[SqlCommand Example#1](~/../sqlclient/doc/samples/SqlCommand.cs#1)]
|
||
|
|
||
|
The following sample shows how to create and execute different types of SqlCommand objects.
|
||
|
|
||
|
First you must create the sample database, by executing the following script:
|
||
|
|
||
|
[!code-sql[Setup Database](~/../sqlclient/doc/samples/SqlCommand_Setup.sql#1)]
|
||
|
|
||
|
Next, compile and execute the following:
|
||
|
|
||
|
[!code-csharp[SqlCommand Example#2](~/../sqlclient/doc/samples/SqlCommand_Intro.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.#ctor">
|
||
|
<summary>
|
||
|
Initializes a new instance of the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlCommand" />
|
||
|
class.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The base constructor initializes all fields to their default values. The following table shows initial property values for an instance of <xref:Microsoft.Data.SqlClient.SqlCommand>.
|
||
|
|
||
|
|Properties|Initial value|
|
||
|
|----------------|-------------------|
|
||
|
|<xref:Microsoft.Data.SqlClient.SqlCommand.CommandText%2A>|empty string ("")|
|
||
|
|<xref:Microsoft.Data.SqlClient.SqlCommand.CommandTimeout%2A>|30|
|
||
|
|<xref:Microsoft.Data.SqlClient.SqlCommand.CommandType%2A>|`CommandType.Text`|
|
||
|
|<xref:Microsoft.Data.SqlClient.SqlCommand.Connection%2A>|Null|
|
||
|
|
||
|
You can change the value for any of these properties through a separate call to the property.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlCommand> and sets the `CommandTimeout` property.
|
||
|
|
||
|
[!code-csharp[Classic WebData IDbCommand_CommandTimeout.cs](~/../sqlclient/doc/samples/IDbCommand_CommandTimeout.cs)]
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.#ctor(System.String)">
|
||
|
<param name="cmdText">
|
||
|
The text of the query.
|
||
|
</param><summary>
|
||
|
Initializes a new instance of the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlCommand" />
|
||
|
class with the text of the query.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
When an instance of <xref:Microsoft.Data.SqlClient.SqlCommand> is created, the following read/write properties are set to initial values.
|
||
|
|
||
|
|Properties|Initial value|
|
||
|
|----------------|-------------------|
|
||
|
|<xref:Microsoft.Data.SqlClient.SqlCommand.CommandText%2A>|`cmdText`|
|
||
|
|<xref:Microsoft.Data.SqlClient.SqlCommand.CommandTimeout%2A>|30|
|
||
|
|<xref:Microsoft.Data.SqlClient.SqlCommand.CommandType%2A>|`CommandType.Text`|
|
||
|
|<xref:Microsoft.Data.SqlClient.SqlCommand.Connection%2A>|null|
|
||
|
|
||
|
You can change the value for any of these properties through a separate call to the property.
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlCommand>, passing in the connection string and command text.
|
||
|
|
||
|
[!code-csharp[SqlCommand_SqlCommand1](~/../sqlclient/doc/samples/SqlCommand_SqlCommand1.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.#ctor(System.String,Microsoft.Data.SqlClient.SqlConnection)">
|
||
|
<param name="cmdText">
|
||
|
The text of the query.
|
||
|
</param><param name="connection">
|
||
|
A
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
that represents the connection to an instance of SQL Server.
|
||
|
</param><summary>
|
||
|
Initializes a new instance of the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlCommand" />
|
||
|
class with the text of the query and a
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The following table shows initial property values for an instance of <xref:Microsoft.Data.SqlClient.SqlCommand>.
|
||
|
|
||
|
|Properties|Initial value|
|
||
|
|----------------|-------------------|
|
||
|
|<xref:Microsoft.Data.SqlClient.SqlCommand.CommandText%2A>|`cmdText`|
|
||
|
|<xref:Microsoft.Data.SqlClient.SqlCommand.CommandTimeout%2A>|30|
|
||
|
|<xref:Microsoft.Data.SqlClient.SqlCommand.CommandType%2A>|`CommandType.Text`|
|
||
|
|<xref:Microsoft.Data.SqlClient.SqlCommand.Connection%2A>|A new <xref:Microsoft.Data.SqlClient.SqlConnection> that is the value for the `connection` parameter.|
|
||
|
|
||
|
You can change the value for any of these parameters by setting the related property.
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlCommand> and sets some of its properties.
|
||
|
|
||
|
[!code-csharp[SqlCommand_SqlCommand2.cs](~/../sqlclient/doc/samples/SqlCommand_SqlCommand2.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.#ctor(System.String,Microsoft.Data.SqlClient.SqlConnection,Microsoft.Data.SqlClient.SqlTransaction)">
|
||
|
<param name="cmdText">
|
||
|
The text of the query.
|
||
|
</param><param name="connection">
|
||
|
A
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
that represents the connection to an instance of SQL Server.
|
||
|
</param><param name="transaction">
|
||
|
The
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlTransaction" />
|
||
|
in which the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlCommand" />
|
||
|
executes.
|
||
|
</param><summary>
|
||
|
Initializes a new instance of the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlCommand" />
|
||
|
class with the text of the query, a
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
, and the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlTransaction" />
|
||
|
.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The following table shows initial property values for an instance of <xref:Microsoft.Data.SqlClient.SqlCommand>.
|
||
|
|
||
|
|Properties|Initial value|
|
||
|
|----------------|-------------------|
|
||
|
|<xref:Microsoft.Data.SqlClient.SqlCommand.CommandText%2A>|`cmdText`|
|
||
|
|<xref:Microsoft.Data.SqlClient.SqlCommand.CommandTimeout%2A>|30|
|
||
|
|<xref:Microsoft.Data.SqlClient.SqlCommand.CommandType%2A>|`CommandType.Text`|
|
||
|
|<xref:Microsoft.Data.SqlClient.SqlCommand.Connection%2A>|A new <xref:Microsoft.Data.SqlClient.SqlConnection> that is the value for the `connection` parameter.|
|
||
|
|
||
|
You can change the value for any of these parameters by setting the related property.
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.#ctor(System.String,Microsoft.Data.SqlClient.SqlConnection,Microsoft.Data.SqlClient.SqlTransaction,Microsoft.Data.SqlClient.SqlCommandColumnEncryptionSetting)">
|
||
|
<param name="cmdText">
|
||
|
The text of the query.
|
||
|
</param><param name="connection">
|
||
|
A
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
that represents the connection to an instance of SQL Server.
|
||
|
</param><param name="transaction">
|
||
|
The
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlTransaction" />
|
||
|
in which the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlCommand" />
|
||
|
executes.
|
||
|
</param><param name="columnEncryptionSetting">
|
||
|
The encryption setting. For more information, see [Always Encrypted](/sql/relational-databases/security/encryption/always-encrypted-database-engine).
|
||
|
</param><summary>
|
||
|
Initializes a new instance of the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlCommand" />
|
||
|
class with specified command text, connection, transaction, and encryption setting.
|
||
|
</summary><remarks>
|
||
|
To be added.
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlCommand.ColumnEncryptionSetting">
|
||
|
<summary>
|
||
|
Gets the column encryption setting for this command.
|
||
|
</summary><value>
|
||
|
The column encryption setting for this command.
|
||
|
</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlCommand.CommandText">
|
||
|
<summary>
|
||
|
Gets or sets the Transact-SQL statement, table name or stored procedure to execute at the data source.
|
||
|
</summary><value>
|
||
|
The Transact-SQL statement or stored procedure to execute. The default is an empty string.
|
||
|
</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
When the <xref:Microsoft.Data.SqlClient.SqlCommand.CommandType%2A> property is set to `StoredProcedure`, the <xref:Microsoft.Data.SqlClient.SqlCommand.CommandText%2A> property should be set to the name of the stored procedure. The user may be required to use escape character syntax if the stored procedure name contains any special characters. The command executes this stored procedure when you call one of the `Execute` methods.
|
||
|
|
||
|
The Microsoft .NET Framework Data Provider for SQL Server does not support the question mark (?) placeholder for passing parameters to a Transact-SQL statement or a stored procedure called by a command of `CommandType.Text`. In this case, named parameters must be used. For example:
|
||
|
|
||
|
```sql
|
||
|
SELECT * FROM dbo.Customers WHERE CustomerID = @CustomerID
|
||
|
```
|
||
|
|
||
|
For more information, see [Configuring parameters](/sql/connect/ado-net/configure-parameters).
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlCommand> and sets some of its properties.
|
||
|
|
||
|
[!code-csharp[SqlCommand_CommandText](~/../sqlclient/doc/samples/SqlCommand_CommandText.cs)]
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlCommand.CommandTimeout">
|
||
|
<summary>
|
||
|
Gets or sets the wait time (in seconds) before terminating the attempt to execute a command and generating an error. The default is 30 seconds.
|
||
|
</summary><value>
|
||
|
The time in seconds to wait for the command to execute. The default is 30 seconds.
|
||
|
</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
A value of 0 indicates no limit (an attempt to execute a command will wait indefinitely).
|
||
|
|
||
|
> [!NOTE]
|
||
|
> The <xref:Microsoft.Data.SqlClient.SqlCommand.CommandTimeout%2A> property will be ignored during old-style asynchronous method calls such as <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReader%2A>. It will be honored by the newer async methods such as <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteReaderAsync%2A>.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> This property is the cumulative time-out (for all network packets that are read during the invocation of a method) for all network reads during command execution or processing of the results. A time-out can still occur after the first row is returned, and does not include user processing time, only network read time.
|
||
|
|
||
|
For example, with a 30 second time out, if <xref:Microsoft.Data.SqlClient.SqlDataReader.Read%2A> requires two network packets, then it has 30 seconds to read both network packets. If you call <xref:Microsoft.Data.SqlClient.SqlDataReader.Read%2A> again, it will have another 30 seconds to read any data that it requires.
|
||
|
|
||
|
[!code-csharp[SqlCommand CommandTimeout](~/../sqlclient/doc/samples/SqlCommand_CommandTimeout.cs)]
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentException">The value set is less than 0.</exception>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlCommand.CommandType">
|
||
|
<summary>
|
||
|
Gets or sets a value indicating how the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlCommand.CommandText" />
|
||
|
property is to be interpreted.
|
||
|
</summary><value>
|
||
|
One of the
|
||
|
<see cref="T:System.Data.CommandType" />
|
||
|
values. The default is
|
||
|
<see langword="Text" />
|
||
|
.
|
||
|
</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
When you set the <xref:Microsoft.Data.SqlClient.SqlCommand.CommandType%2A> property to `StoredProcedure`, you should set the <xref:Microsoft.Data.SqlClient.SqlCommand.CommandText%2A> property to the name of the stored procedure. The command executes this stored procedure when you call one of the Execute methods.
|
||
|
|
||
|
The Microsoft .NET Framework Data Provider for SQL Server does not support the question mark (?) placeholder for passing parameters to a SQL Statement or a stored procedure called with a <xref:Microsoft.Data.SqlClient.SqlCommand.CommandType%2A> of <xref:System.Data.CommandType.Text>. In this case, named parameters must be used. For example:
|
||
|
|
||
|
SELECT * FROM Customers WHERE CustomerID = @CustomerID
|
||
|
|
||
|
For more information, see [Configuring parameters](/sql/connect/ado-net/configure-parameters).
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlCommand> and sets some of its properties.
|
||
|
|
||
|
[!code-csharp[IDbCommand_CommandTimeout](~/../sqlclient/doc/samples/IDbCommand_CommandTimeout.cs)]
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlCommand.Connection">
|
||
|
<summary>
|
||
|
Gets or sets the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
used by this instance of the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlCommand" />
|
||
|
.
|
||
|
</summary><value>
|
||
|
The connection to a data source. The default value is
|
||
|
<see langword="null" />
|
||
|
.
|
||
|
</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
If the command is enlisted in an existing transaction, and the connection is changed, trying to execute the command will throw an <xref:System.InvalidOperationException>.
|
||
|
|
||
|
If the <xref:Microsoft.Data.SqlClient.SqlCommand.Transaction%2A> property is not null and the transaction has already been committed or rolled back, <xref:Microsoft.Data.SqlClient.SqlCommand.Transaction%2A> is set to null.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlCommand> and sets some of its properties.
|
||
|
|
||
|
[!code-csharp[SqlCommand_Connection](~/../sqlclient/doc/samples/SqlCommand_Connection.cs)]
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidOperationException">
|
||
|
The
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlCommand.Connection" />
|
||
|
property was changed while the command was enlisted in a transaction.
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlCommand.DbConnection">
|
||
|
<summary>
|
||
|
To be added.
|
||
|
</summary><value>
|
||
|
To be added.
|
||
|
</value><remarks>
|
||
|
To be added.
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlCommand.DbParameterCollection">
|
||
|
<summary>
|
||
|
Gets the collection of <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> objects.
|
||
|
</summary><value>
|
||
|
The parameters of the SQL statement or stored procedure.
|
||
|
</value><remarks>
|
||
|
To be added.
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlCommand.DbTransaction">
|
||
|
<summary>
|
||
|
To be added.
|
||
|
</summary><value>
|
||
|
To be added.
|
||
|
</value><remarks>
|
||
|
To be added.
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlCommand.DesignTimeVisible">
|
||
|
<summary>
|
||
|
Gets or sets a value indicating whether the command object should be visible in a Windows Form Designer control.
|
||
|
</summary><value>
|
||
|
A value indicating whether the command object should be visible in a control. The default is
|
||
|
<see langword="true" />
|
||
|
.
|
||
|
</value><remarks>
|
||
|
To be added.
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlCommand.EnableOptimizedParameterBinding">
|
||
|
<summary>
|
||
|
Gets or sets a value indicating whether the command object should optimize parameter performance by disabling Output and InputOutput directions when submitting the command to the SQL Server.
|
||
|
</summary><value>
|
||
|
A value indicating whether the command object should optimize parameter performance by disabling Output and InputOuput parameter directions when submitting the command to the SQL Server.
|
||
|
The default is <see langword="false" />.
|
||
|
</value><remarks>
|
||
|
<format type="text/markdown">
|
||
|
<![CDATA[
|
||
|
## Remarks
|
||
|
You must set the value for this property before the command is executed for it to take effect.
|
||
|
|
||
|
When a command is submitted to the server with parameters a list of the parameter names is sent as part of the submission. The list is used on the server to match Output and InputOutput parameters to the results of the query execution so that the values can be returned to the caller. This option disables the construction and submission of the parameter name list and as a consequence disables the use of Output and InputOutput parameters. The return parameter is not affected by this option.
|
||
|
|
||
|
A command sent with this option changes the way parameters are handled on the server, because there is no need to maintain an output parameter map. The result of this change is that queries with large numbers of input parameters may execute much faster.
|
||
|
|
||
|
The fewest number of parameters where this will take effect depends on the individual situation and should be detected by measuring query duration with and without the option enabled. Any query with more than 24 parameters may show lower overall query duration. Queries with parameter counts lower than 24 are unlikely to show a difference.
|
||
|
|
||
|
> [!NOTE]
|
||
|
If the option is enabled and a parameter with Direction Output or InputOutput is present in the Parameters collection an InvalidOperationException will be thrown when the command is executed.
|
||
|
|
||
|
]]>
|
||
|
</format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlCommand.Parameters">
|
||
|
<summary>
|
||
|
Gets the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" />
|
||
|
.
|
||
|
</summary><value>
|
||
|
The parameters of the Transact-SQL statement or stored procedure. The default is an empty collection.
|
||
|
</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The Microsoft .NET Framework Data Provider for SQL Server does not support the question mark (?) placeholder for passing parameters to a SQL Statement or a stored procedure called by a command of `CommandType.Text`. In this case, named parameters must be used. For example:
|
||
|
|
||
|
SELECT * FROM Customers WHERE CustomerID = @CustomerID
|
||
|
|
||
|
> [!NOTE]
|
||
|
> If the parameters in the collection do not match the requirements of the query to be executed, an error may result.
|
||
|
|
||
|
For more information, see [Configuring parameters](/sql/connect/ado-net/configure-parameters).
|
||
|
|
||
|
## Examples
|
||
|
The following example demonstrates how to create a <xref:Microsoft.Data.SqlClient.SqlCommand> and add parameters to the <xref:Microsoft.Data.SqlClient.SqlParameterCollection>.
|
||
|
|
||
|
[!code-csharp[SqlParameterCollection.AddWithValue#1](~/../sqlclient/doc/samples/SqlParameterCollection_AddWithValue.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlCommand.Transaction">
|
||
|
<summary>
|
||
|
Gets or sets the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlTransaction" />
|
||
|
within which the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlCommand" />
|
||
|
executes.
|
||
|
</summary><value>
|
||
|
The
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlTransaction" />
|
||
|
. The default value is
|
||
|
<see langword="null" />
|
||
|
.
|
||
|
</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
You cannot set the <xref:Microsoft.Data.SqlClient.SqlCommand.Transaction%2A> property if it is already set to a specific value, and the command is in the process of executing. If you set the transaction property to a <xref:Microsoft.Data.SqlClient.SqlTransaction> object that is not connected to the same <xref:Microsoft.Data.SqlClient.SqlConnection> as the <xref:Microsoft.Data.SqlClient.SqlCommand> object, an exception is thrown the next time that you attempt to execute a statement.
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlCommand.UpdatedRowSource">
|
||
|
<summary>
|
||
|
Gets or sets how command results are applied to the <see cref="T:System.Data.DataRow" /> when used by the **Update** method of the <see cref="T:System.Data.Common.DbDataAdapter" />.
|
||
|
</summary><value>
|
||
|
One of the <see cref="T:System.Data.UpdateRowSource" /> values.
|
||
|
</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The default <xref:System.Data.UpdateRowSource> value is **Both** unless the command is automatically generated (as in the case of the <xref:Microsoft.Data.SqlClient.SqlCommandBuilder>), in which case the default is **None**.
|
||
|
|
||
|
For more information about using the **UpdatedRowSource** property, see [DataAdapter Parameters](/sql/connect/ado-net/dataadapter-parameters).
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="E:Microsoft.Data.SqlClient.SqlCommand.StatementCompleted">
|
||
|
<summary>
|
||
|
Occurs when the execution of a Transact-SQL statement completes.
|
||
|
</summary><remarks>
|
||
|
To be added.
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteNonQuery">
|
||
|
<summary>
|
||
|
Initiates the asynchronous execution of the Transact-SQL statement or stored procedure that is described by this
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlCommand" />
|
||
|
.
|
||
|
</summary><returns>
|
||
|
An
|
||
|
<see cref="T:System.IAsyncResult" />
|
||
|
that can be used to poll or wait for results, or both; this value is also needed when invoking
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.EndExecuteNonQuery(System.IAsyncResult)" />
|
||
|
, which returns the number of affected rows.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteNonQuery%2A> method starts the process of asynchronously executing a Transact-SQL statement or stored procedure that does not return rows, so that other tasks can run concurrently while the statement is executing. When the statement has completed, developers must call the <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteNonQuery%2A> method to finish the operation. The <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteNonQuery%2A> method returns immediately, but until the code executes the corresponding <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteNonQuery%2A> method call, it must not execute any other calls that start a synchronous or asynchronous execution against the same <xref:Microsoft.Data.SqlClient.SqlCommand> object. Calling the <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteNonQuery%2A> before the command's execution is completed causes the <xref:Microsoft.Data.SqlClient.SqlCommand> object to block until the execution is finished.
|
||
|
|
||
|
Note that the command text and parameters are sent to the server synchronously. If a large command or many parameters are sent, this method may block during writes. After the command is sent, the method returns immediately without waiting for an answer from the server--that is, reads are asynchronous.
|
||
|
|
||
|
Because this overload does not support a callback procedure, developers must either poll to determine whether the command has completed, using the <xref:System.IAsyncResult.IsCompleted%2A> property of the <xref:System.IAsyncResult> returned by the <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteNonQuery%2A> method; or wait for the completion of one or more commands using the <xref:System.IAsyncResult.AsyncWaitHandle%2A> property of the returned <xref:System.IAsyncResult>.
|
||
|
|
||
|
This method ignores the <xref:Microsoft.Data.SqlClient.SqlCommand.CommandTimeout%2A> property.
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following console application creates updates data within the **AdventureWorks** sample database, doing its work asynchronously. In order to emulate a long-running process, this example inserts a WAITFOR statement in the command text. Normally, you would not take efforts to make your commands run slower, but doing this in this case makes it easier to demonstrate the asynchronous behavior.
|
||
|
|
||
|
[!code-csharp[SqlCommand_BeginExecuteNonQuery](~/../sqlclient/doc/samples/SqlCommand_BeginExecuteNonQuery.cs)]
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Binary** or **VarBinary** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Char**, **NChar**, **NVarChar**, **VarChar**, or **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
.
|
||
|
</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">
|
||
|
Any error that occurred while executing the command text.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A timeout occurred during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.InvalidOperationException">
|
||
|
The
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
closed or dropped during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
- or -
|
||
|
|
||
|
<see cref="P:Microssoft.Data.SqlClient.SqlCommand.EnableOptimizedParameterBinding" />
|
||
|
is set to true and a parameter with direction Output or InputOutput has been added to the <see cref="P:Microsoft.Data.SqlClient.SqlCommand.Parameters" /> collection.
|
||
|
</exception><exception cref="T:System.IO.IOException">
|
||
|
An error occurred in a
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.ObjectDisposedException">
|
||
|
The
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object was closed during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteNonQuery(System.AsyncCallback,System.Object)">
|
||
|
<param name="callback">
|
||
|
An
|
||
|
<see cref="T:System.AsyncCallback" />
|
||
|
delegate that is invoked when the command's execution has completed. Pass
|
||
|
<see langword="null" />
|
||
|
(
|
||
|
<see langword="Nothing" />
|
||
|
in Microsoft Visual Basic) to indicate that no callback is required.
|
||
|
</param><param name="stateObject">
|
||
|
A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback procedure using the
|
||
|
<see cref="P:System.IAsyncResult.AsyncState" />
|
||
|
property.
|
||
|
</param><summary>
|
||
|
Initiates the asynchronous execution of the Transact-SQL statement or stored procedure that is described by this
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlCommand" />
|
||
|
, given a callback procedure and state information.
|
||
|
</summary><returns>
|
||
|
An
|
||
|
<see cref="T:System.IAsyncResult" />
|
||
|
that can be used to poll or wait for results, or both; this value is also needed when invoking
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.EndExecuteNonQuery(System.IAsyncResult)" />
|
||
|
, which returns the number of affected rows.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteNonQuery%2A> method starts the process of asynchronously executing a Transact-SQL statement or stored procedure that does not return rows, so that other tasks can run concurrently while the statement is executing. When the statement has completed, developers must call the <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteNonQuery%2A> method to finish the operation. The <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteNonQuery%2A> method returns immediately, but until the code executes the corresponding <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteNonQuery%2A> method call, it must not execute any other calls that start a synchronous or asynchronous execution against the same <xref:Microsoft.Data.SqlClient.SqlCommand> object. Calling the <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteNonQuery%2A> before the command's execution is completed causes the <xref:Microsoft.Data.SqlClient.SqlCommand> object to block until the execution is finished.
|
||
|
|
||
|
The `callback` parameter lets you specify an <xref:System.AsyncCallback> delegate that is called when the statement has completed. You can call the <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteNonQuery%2A> method from within this delegate procedure, or from any other location within your application. In addition, you can pass any object in the `asyncStateObject` parameter, and your callback procedure can retrieve this information using the <xref:System.IAsyncResult.AsyncState%2A> property.
|
||
|
|
||
|
Note that the command text and parameters are sent to the server synchronously. If a large command or many parameters are sent, this method may block during writes. After the command is sent, the method returns immediately without waiting for an answer from the server--that is, reads are asynchronous.
|
||
|
|
||
|
Because the callback procedure executes from within a background thread supplied by the Microsoft .NET common language runtime, it is very important that you take a rigorous approach to handling cross-thread interactions from within your applications. For example, you must not interact with a form's contents from within your callback procedure; should you have to update the form, you must switch back to the form's thread in order to do your work. The example in this topic demonstrates this behavior.
|
||
|
|
||
|
All errors that occur during the execution of the operation are thrown as exceptions in the callback procedure. You must handle the exception in the callback procedure, not in the main application. See the example in this topic for additional information on handling exceptions in the callback procedure.
|
||
|
|
||
|
This method ignores the <xref:Microsoft.Data.SqlClient.SqlCommand.CommandTimeout%2A> property.
|
||
|
|
||
|
## Examples
|
||
|
The following Windows application demonstrates the use of the <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteNonQuery%2A> method, executing a Transact-SQL statement that includes a delay of several seconds (emulating a long-running command).
|
||
|
|
||
|
This example demonstrates many important techniques. This includes calling a method that interacts with the form from a separate thread. In addition, this example demonstrates how you must block users from executing a command multiple times concurrently, and how you must make sure that the form does not close before the callback procedure is called.
|
||
|
|
||
|
To set up this example, create a new Windows application. Put a <xref:System.Windows.Forms.Button> control and a <xref:System.Windows.Forms.Label> control on the form (accepting the default name for each control). Add the following code to the form's class, modifying the connection string as needed for your environment.
|
||
|
|
||
|
[!code-csharp[DataWorks SqlCommand_BeginExecuteNonQueryForm#1](~/../sqlclient/doc/samples/SqlCommand_BeginExecuteNonQueryForm.cs)]
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Binary** or **VarBinary** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Char**, **NChar**, **NVarChar**, **VarChar**, or **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
.
|
||
|
</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">
|
||
|
Any error that occurred while executing the command text.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A timeout occurred during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.InvalidOperationException">
|
||
|
The
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
closed or dropped during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
- or -
|
||
|
|
||
|
<see cref="P:Microssoft.Data.SqlClient.SqlCommand.EnableOptimizedParameterBinding" />
|
||
|
is set to true and a parameter with direction Output or InputOutput has been added to the <see cref="P:Microsoft.Data.SqlClient.SqlCommand.Parameters" /> collection.
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReader">
|
||
|
<summary>
|
||
|
Initiates the asynchronous execution of the Transact-SQL statement or stored procedure that is described by this
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlCommand" />
|
||
|
, and retrieves one or more result sets from the server.
|
||
|
</summary><returns>
|
||
|
An
|
||
|
<see cref="T:System.IAsyncResult" />
|
||
|
that can be used to poll or wait for results, or both; this value is also needed when invoking
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.EndExecuteReader(System.IAsyncResult)" />
|
||
|
, which returns a
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlDataReader" />
|
||
|
instance that can be used to retrieve the returned rows.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReader%2A> method starts the process of asynchronously executing a Transact-SQL statement or stored procedure that returns rows, so that other tasks can run concurrently while the statement is executing. When the statement has completed, developers must call the <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteReader%2A> method to finish the operation and retrieve the <xref:Microsoft.Data.SqlClient.SqlDataReader> returned by the command. The <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReader%2A> method returns immediately, but until the code executes the corresponding <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteReader%2A> method call, it must not execute any other calls that start a synchronous or asynchronous execution against the same <xref:Microsoft.Data.SqlClient.SqlCommand> object. Calling the <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteReader%2A> before the command's execution is completed causes the <xref:Microsoft.Data.SqlClient.SqlCommand> object to block until the execution is finished.
|
||
|
|
||
|
Note that the command text and parameters are sent to the server synchronously. If a large command or many parameters are sent, this method may block during writes. After the command is sent, the method returns immediately without waiting for an answer from the server--that is, reads are asynchronous. Although command execution is asynchronous, value fetching is still synchronous. This means that calls to <xref:Microsoft.Data.SqlClient.SqlDataReader.Read%2A> may block if more data is required and the underlying network's read operation blocks.
|
||
|
|
||
|
Because this overload does not support a callback procedure, developers must either poll to determine whether the command has completed, using the <xref:System.IAsyncResult.IsCompleted%2A> property of the <xref:System.IAsyncResult> returned by the <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReader%2A> method; or wait for the completion of one or more commands using the <xref:System.IAsyncResult.AsyncWaitHandle%2A> property of the returned <xref:System.IAsyncResult>.
|
||
|
|
||
|
If you use <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteReader%2A> or <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReader%2A> to access XML data, SQL Server will return any XML results greater than 2,033 characters in length in multiple rows of 2,033 characters each. To avoid this behavior, use <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteXmlReader%2A> or <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteXmlReader%2A> to read FOR XML queries.
|
||
|
|
||
|
This method ignores the <xref:Microsoft.Data.SqlClient.SqlCommand.CommandTimeout%2A> property.
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following console application starts the process of retrieving a data reader asynchronously. While waiting for the results, this simple application sits in a loop, investigating the <xref:System.IAsyncResult.IsCompleted%2A> property value. As soon as the process has completed, the code retrieves the <xref:Microsoft.Data.SqlClient.SqlDataReader> and displays its contents.
|
||
|
|
||
|
[!code-csharp[SqlCommand_BeginExecuteReader#1](~/../sqlclient/doc/samples/SqlCommand_BeginExecuteReader.cs)]
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Binary** or **VarBinary** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Char**, **NChar**, **NVarChar**, **VarChar**, or **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
.
|
||
|
</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">
|
||
|
Any error that occurred while executing the command text.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A timeout occurred during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.InvalidOperationException">
|
||
|
The
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
closed or dropped during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
- or -
|
||
|
|
||
|
<see cref="P:Microssoft.Data.SqlClient.SqlCommand.EnableOptimizedParameterBinding" />
|
||
|
is set to true and a parameter with direction Output or InputOutput has been added to the <see cref="P:Microsoft.Data.SqlClient.SqlCommand.Parameters" /> collection.
|
||
|
</exception><exception cref="T:System.IO.IOException">
|
||
|
An error occurred in a
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.ObjectDisposedException">
|
||
|
The
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object was closed during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReader(System.AsyncCallback,System.Object)">
|
||
|
<param name="callback">
|
||
|
An
|
||
|
<see cref="T:System.AsyncCallback" />
|
||
|
delegate that is invoked when the command's execution has completed. Pass
|
||
|
<see langword="null" />
|
||
|
(
|
||
|
<see langword="Nothing" />
|
||
|
in Microsoft Visual Basic) to indicate that no callback is required.
|
||
|
</param><param name="stateObject">
|
||
|
A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback procedure using the
|
||
|
<see cref="P:System.IAsyncResult.AsyncState" />
|
||
|
property.
|
||
|
</param><summary>
|
||
|
Initiates the asynchronous execution of the Transact-SQL statement or stored procedure that is described by this
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlCommand" />
|
||
|
and retrieves one or more result sets from the server, given a callback procedure and state information.
|
||
|
</summary><returns>
|
||
|
An
|
||
|
<see cref="T:System.IAsyncResult" />
|
||
|
that can be used to poll, wait for results, or both; this value is also needed when invoking
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.EndExecuteReader(System.IAsyncResult)" />
|
||
|
, which returns a
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlDataReader" />
|
||
|
instance which can be used to retrieve the returned rows.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReader%2A> method starts the process of asynchronously executing a Transact-SQL statement or stored procedure that returns rows, so that other tasks can run concurrently while the statement is executing. When the statement has completed, developers must call the <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteReader%2A> method to finish the operation and retrieve the <xref:Microsoft.Data.SqlClient.SqlDataReader> returned by the command. The <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReader%2A> method returns immediately, but until the code executes the corresponding <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteReader%2A> method call, it must not execute any other calls that start a synchronous or asynchronous execution against the same <xref:Microsoft.Data.SqlClient.SqlCommand> object. Calling the <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteReader%2A> before the command's execution is completed cause the <xref:Microsoft.Data.SqlClient.SqlCommand> object to block until the execution is finished.
|
||
|
|
||
|
The `callback` parameter lets you specify an <xref:System.AsyncCallback> delegate that is called when the statement has completed. You can call the <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteReader%2A> method from within this delegate procedure, or from any other location within your application. In addition, you can pass any object in the `stateObject` parameter, and your callback procedure can retrieve this information using the <xref:System.IAsyncResult.AsyncState%2A> property.
|
||
|
|
||
|
Note that the command text and parameters are sent to the server synchronously. If a large command or many parameters are sent, this method may block during writes. After the command is sent, the method returns immediately without waiting for an answer from the server--that is, reads are asynchronous. Although command execution is asynchronous, value fetching is still synchronous. This means that calls to <xref:Microsoft.Data.SqlClient.SqlDataReader.Read%2A> may block if more data is required and the underlying network's read operation blocks.
|
||
|
|
||
|
Because the callback procedure executes from within a background thread supplied by the Microsoft .NET runtime, it is very important that you take a rigorous approach to handling cross-thread interactions from within your applications. For example, you must not interact with a form's contents from within your callback procedure; should you have to update the form, you must switch back to the form's thread in order to do your work. The example in this topic demonstrates this behavior.
|
||
|
|
||
|
All errors that occur during the execution of the operation are thrown as exceptions in the callback procedure. You must handle the exception in the callback procedure, not in the main application. See the example in this topic for additional information on handling exceptions in the callback procedure.
|
||
|
|
||
|
If you use <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteReader%2A> or <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReader%2A> to access XML data, SQL Server returns any XML results greater than 2,033 characters in length in multiple rows of 2,033 characters each. To avoid this behavior, use <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteXmlReader%2A> or <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteXmlReader%2A> to read FOR XML queries.
|
||
|
|
||
|
This method ignores the <xref:Microsoft.Data.SqlClient.SqlCommand.CommandTimeout%2A> property.
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following Windows application demonstrates the use of the <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReader%2A> method, executing a Transact-SQL statement that includes a delay of a few seconds (emulating a long-running command). Because the sample executes the command asynchronously, the form remains responsive while awaiting the results. This example passes the executing <xref:Microsoft.Data.SqlClient.SqlCommand> object as the `stateObject` parameter; doing so makes it simple to retrieve the <xref:Microsoft.Data.SqlClient.SqlCommand> object from within the callback procedure, so that the code can call the <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteReader%2A> method corresponding to the initial call to <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReader%2A>.
|
||
|
|
||
|
This example demonstrates many important techniques. This includes calling a method that interacts with the form from a separate thread. In addition, this example demonstrates how you must block users from executing a command multiple times concurrently, and how you must make sure that the form does not close before the callback procedure is called.
|
||
|
|
||
|
To set up this example, create a new Windows application. Put a <xref:System.Windows.Forms.Button> control, a <xref:System.Windows.Forms.DataGridView> control, and a <xref:System.Windows.Forms.Label> control on the form (accepting the default name for each control). Add the following code to the form's class, modifying the connection string as needed for your environment.
|
||
|
|
||
|
[!code-csharp[SqlCommand_BeginExecuteReaderAsync.cs](~/../sqlclient/doc/samples/SqlCommand_BeginExecuteReaderAsync.cs)]
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Binary** or **VarBinary** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Char**, **NChar**, **NVarChar**, **VarChar**, or **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
.
|
||
|
</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">
|
||
|
Any error that occurred while executing the command text.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A timeout occurred during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.InvalidOperationException">
|
||
|
The
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
closed or dropped during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
- or -
|
||
|
|
||
|
<see cref="P:Microssoft.Data.SqlClient.SqlCommand.EnableOptimizedParameterBinding" />
|
||
|
is set to true and a parameter with direction Output or InputOutput has been added to the <see cref="P:Microsoft.Data.SqlClient.SqlCommand.Parameters" /> collection.
|
||
|
</exception><exception cref="T:System.IO.IOException">
|
||
|
An error occurred in a
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.ObjectDisposedException">
|
||
|
The
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object was closed during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReader(System.AsyncCallback,System.Object,System.Data.CommandBehavior)">
|
||
|
<param name="callback">
|
||
|
An
|
||
|
<see cref="T:System.AsyncCallback" />
|
||
|
delegate that is invoked when the command's execution has completed. Pass
|
||
|
<see langword="null" />
|
||
|
(
|
||
|
<see langword="Nothing" />
|
||
|
in Microsoft Visual Basic) to indicate that no callback is required.
|
||
|
</param><param name="stateObject">
|
||
|
A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback procedure using the
|
||
|
<see cref="P:System.IAsyncResult.AsyncState" />
|
||
|
property.
|
||
|
</param><param name="behavior">
|
||
|
One of the
|
||
|
<see cref="T:System.Data.CommandBehavior" />
|
||
|
values, indicating options for statement execution and data retrieval.
|
||
|
</param><summary>
|
||
|
Initiates the asynchronous execution of the Transact-SQL statement or stored procedure that is described by this
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlCommand" />
|
||
|
, using one of the
|
||
|
<see langword="CommandBehavior" />
|
||
|
values, and retrieving one or more result sets from the server, given a callback procedure and state information.
|
||
|
</summary><returns>
|
||
|
An
|
||
|
<see cref="T:System.IAsyncResult" />
|
||
|
that can be used to poll or wait for results, or both; this value is also needed when invoking
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.EndExecuteReader(System.IAsyncResult)" />
|
||
|
, which returns a
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlDataReader" />
|
||
|
instance which can be used to retrieve the returned rows.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReader%2A> method starts the process of asynchronously executing a Transact-SQL statement or stored procedure that returns rows, so that other tasks can run concurrently while the statement is executing. When the statement has completed, developers must call the <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteReader%2A> method to finish the operation and retrieve the <xref:Microsoft.Data.SqlClient.SqlDataReader> returned by the command. The <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReader%2A> method returns immediately, but until the code executes the corresponding <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteReader%2A> method call, it must not execute any other calls that start a synchronous or asynchronous execution against the same <xref:Microsoft.Data.SqlClient.SqlCommand> object. Calling the <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteReader%2A> before the command's execution is completed causes the <xref:Microsoft.Data.SqlClient.SqlCommand> object to block until the execution is finished.
|
||
|
|
||
|
The `callback` parameter lets you specify an <xref:System.AsyncCallback> delegate that is called when the statement has completed. You can call the <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteReader%2A> method from within this delegate procedure, or from any other location within your application. In addition, you can pass any object in the `stateObject` parameter, and your callback procedure can retrieve this information using the <xref:System.IAsyncResult.AsyncState%2A> property.
|
||
|
|
||
|
The `behavior` parameter lets you specify options that control the behavior of the command and its connection. These values can be combined together (using the programming language's `Or` operator); generally, developers use the `CloseConnection` value to make sure that the connection is closed by the runtime when the <xref:Microsoft.Data.SqlClient.SqlDataReader> is closed. Developers can also optimize the behavior of the <xref:Microsoft.Data.SqlClient.SqlDataReader> by specifying the `SingleRow` value when it is known in advance that the Transact-SQL statement or stored procedure only returns a single row.
|
||
|
|
||
|
Note that the command text and parameters are sent to the server synchronously. If a large command or many parameters are sent, this method may block during writes. After the command is sent, the method returns immediately without waiting for an answer from the server--that is, reads are asynchronous. Although command execution is asynchronous, value fetching is still synchronous. This means that calls to <xref:Microsoft.Data.SqlClient.SqlDataReader.Read%2A> may block if more data is required and the underlying network's read operation blocks.
|
||
|
|
||
|
Because the callback procedure executes from within a background thread supplied by the Microsoft .NET common language runtime, it is very important that you take a rigorous approach to handling cross-thread interactions from within your applications. For example, you must not interact with a form's contents from within your callback procedure--should you have to update the form, you must switch back to the form's thread in order to do your work. The example in this topic demonstrates this behavior.
|
||
|
|
||
|
All errors that occur during the execution of the operation are thrown as exceptions in the callback procedure. You must handle the exception in the callback procedure, not in the main application. See the example in this topic for additional information on handling exceptions in the callback procedure.
|
||
|
|
||
|
If you use <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteReader%2A> or <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReader%2A> to access XML data, SQL Server will return any XML results greater than 2,033 characters in length in multiple rows of 2,033 characters each. To avoid this behavior, use <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteXmlReader%2A> or <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteXmlReader%2A> to read FOR XML queries.
|
||
|
|
||
|
This method ignores the <xref:Microsoft.Data.SqlClient.SqlCommand.CommandTimeout%2A> property.
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following Windows application demonstrates the use of the <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReader%2A> method, executing a Transact-SQL statement that includes a delay of a few seconds (emulating a long-running command). Because the sample executes the command asynchronously, the form remains responsive while awaiting the results. This example passes the executing <xref:Microsoft.Data.SqlClient.SqlCommand> object as the `stateObject` parameter; doing so makes it simple to retrieve the <xref:Microsoft.Data.SqlClient.SqlCommand> object from within the callback procedure, so that the code can call the <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteReader%2A> method corresponding to the initial call to <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReader%2A>.
|
||
|
|
||
|
This example demonstrates many important techniques. This includes calling a method that interacts with the form from a separate thread. In addition, this example demonstrates how you must block users from executing a command multiple times concurrently, and how you must make sure that the form does not close before the callback procedure is called.
|
||
|
|
||
|
To set up this example, create a new Windows application. Put a <xref:System.Windows.Forms.Button> control, a <xref:System.Windows.Forms.DataGridView> control, and a <xref:System.Windows.Forms.Label> control on the form (accepting the default name for each control). Add the following code to the form's class, modifying the connection string as needed for your environment.
|
||
|
|
||
|
This example passes the `CommandBehavior.CloseConnection` value in the `behavior` parameter, causing the returned <xref:Microsoft.Data.SqlClient.SqlDataReader> to automatically close its connection when it is closed.
|
||
|
|
||
|
[!code-csharp[SqlCommand_BeginExecuteReaderAsyncBehavior](~/../sqlclient/doc/samples/SqlCommand_BeginExecuteReaderAsyncBehavior.cs)]
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Binary** or **VarBinary** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Char**, **NChar**, **NVarChar**, **VarChar**, or **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
.
|
||
|
</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">
|
||
|
Any error that occurred while executing the command text.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A timeout occurred during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.InvalidOperationException">
|
||
|
The
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
closed or dropped during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
- or -
|
||
|
|
||
|
<see cref="P:Microssoft.Data.SqlClient.SqlCommand.EnableOptimizedParameterBinding" />
|
||
|
is set to true and a parameter with direction Output or InputOutput has been added to the <see cref="P:Microsoft.Data.SqlClient.SqlCommand.Parameters" /> collection.
|
||
|
</exception><exception cref="T:System.IO.IOException">
|
||
|
An error occurred in a
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.ObjectDisposedException">
|
||
|
The
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object was closed during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReader(System.Data.CommandBehavior)">
|
||
|
<param name="behavior">
|
||
|
One of the
|
||
|
<see cref="T:System.Data.CommandBehavior" />
|
||
|
values, indicating options for statement execution and data retrieval.
|
||
|
</param><summary>
|
||
|
Initiates the asynchronous execution of the Transact-SQL statement or stored procedure that is described by this
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlCommand" />
|
||
|
using one of the
|
||
|
<see cref="T:System.Data.CommandBehavior" />
|
||
|
values.
|
||
|
</summary><returns>
|
||
|
An
|
||
|
<see cref="T:System.IAsyncResult" />
|
||
|
that can be used to poll, wait for results, or both; this value is also needed when invoking
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.EndExecuteReader(System.IAsyncResult)" />
|
||
|
, which returns a
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlDataReader" />
|
||
|
instance that can be used to retrieve the returned rows.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReader%2A> method starts the process of asynchronously executing a Transact-SQL statement or stored procedure that returns rows, so that other tasks can run concurrently while the statement is executing. When the statement has completed, developers must call the <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteReader%2A> method to finish the operation and retrieve the <xref:Microsoft.Data.SqlClient.SqlDataReader> returned by the command. The <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReader%2A> method returns immediately, but until the code executes the corresponding <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteReader%2A> method call, it must not execute any other calls that start a synchronous or asynchronous execution against the same <xref:Microsoft.Data.SqlClient.SqlCommand> object. Calling the <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteReader%2A> before the command's execution is completed causes the <xref:Microsoft.Data.SqlClient.SqlCommand> object to block until the execution is finished.
|
||
|
|
||
|
The `behavior` parameter lets you specify options that control the behavior of the command and its connection. These values can be combined together (using the programming language's `OR` operator); generally, developers use the `CommandBehavior.CloseConnection` value to make sure that the connection is closed by the runtime when the <xref:Microsoft.Data.SqlClient.SqlDataReader> is closed.
|
||
|
|
||
|
Note that the command text and parameters are sent to the server synchronously. If a large command or many parameters are sent, this method may block during writes. After the command is sent, the method returns immediately without waiting for an answer from the server--that is, reads are asynchronous. Although command execution is asynchronous, value fetching is still synchronous. This means that calls to <xref:Microsoft.Data.SqlClient.SqlDataReader.Read%2A> may block if more data is required and the underlying network's read operation blocks.
|
||
|
|
||
|
Because this overload does not support a callback procedure, developers must either poll to determine whether the command has completed, using the <xref:System.IAsyncResult.IsCompleted%2A> property of the <xref:System.IAsyncResult> returned by the <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteNonQuery%2A> method; or wait for the completion of one or more commands using the <xref:System.IAsyncResult.AsyncWaitHandle%2A> property of the returned <xref:System.IAsyncResult>.
|
||
|
|
||
|
If you use <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteReader%2A> or <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReader%2A> to access XML data, SQL Server returns any XML results greater than 2,033 characters in length in multiple rows of 2,033 characters each. To avoid this behavior, use <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteXmlReader%2A> or <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteXmlReader%2A> to read FOR XML queries.
|
||
|
|
||
|
This method ignores the <xref:Microsoft.Data.SqlClient.SqlCommand.CommandTimeout%2A> property.
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following console application starts the process of retrieving a data reader asynchronously. While waiting for the results, this simple application sits in a loop, investigating the <xref:System.IAsyncResult.IsCompleted%2A> property value. Once the process has completed, the code retrieves the <xref:Microsoft.Data.SqlClient.SqlDataReader> and displays its contents.
|
||
|
|
||
|
This example also passes the `CommandBehavior.CloseConnection` and `CommandBehavior.SingleRow` values in the behavior parameter, causing the connection to be closed with the returned <xref:Microsoft.Data.SqlClient.SqlDataReader> is closed, and to optimize for a single row result.
|
||
|
|
||
|
[!code-csharp[SqlCommand_BeginExecuteReaderAsyncSimple](~/../sqlclient/doc/samples/SqlCommand_BeginExecuteReaderAsyncSimple.cs)]
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Binary** or **VarBinary** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Char**, **NChar**, **NVarChar**, **VarChar**, or **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
.
|
||
|
</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">
|
||
|
Any error that occurred while executing the command text.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A timeout occurred during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.InvalidOperationException">
|
||
|
The
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
closed or dropped during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
- or -
|
||
|
|
||
|
<see cref="P:Microssoft.Data.SqlClient.SqlCommand.EnableOptimizedParameterBinding" />
|
||
|
is set to true and a parameter with direction Output or InputOutput has been added to the <see cref="P:Microsoft.Data.SqlClient.SqlCommand.Parameters" /> collection.
|
||
|
</exception><exception cref="T:System.IO.IOException">
|
||
|
An error occurred in a
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.ObjectDisposedException">
|
||
|
The
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object was closed during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteXmlReader">
|
||
|
<summary>
|
||
|
Initiates the asynchronous execution of the Transact-SQL statement or stored procedure that is described by this
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlCommand" />
|
||
|
and returns results as an
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
object.
|
||
|
</summary><returns>
|
||
|
An
|
||
|
<see cref="T:System.IAsyncResult" />
|
||
|
that can be used to poll or wait for results, or both; this value is also needed when invoking
|
||
|
<see langword="EndExecuteXmlReader" />
|
||
|
, which returns a single XML value.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteXmlReader%2A> method starts the process of asynchronously executing a Transact-SQL statement that returns rows as XML, so that other tasks can run concurrently while the statement is executing. When the statement has completed, developers must call the `EndExecuteXmlReader` method to finish the operation and retrieve the XML returned by the command. The <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteXmlReader%2A> method returns immediately, but until the code executes the corresponding `EndExecuteXmlReader` method call, it must not execute any other calls that start a synchronous or asynchronous execution against the same <xref:Microsoft.Data.SqlClient.SqlCommand> object. Calling the `EndExecuteXmlReader` before the command's execution is completed causes the <xref:Microsoft.Data.SqlClient.SqlCommand> object to block until the execution is finished.
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlCommand.CommandText%2A> property ordinarily specifies a Transact-SQL statement with a valid FOR XML clause. However, `CommandText` can also specify a statement that returns `ntext` data that contains valid XML.
|
||
|
|
||
|
A typical <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteXmlReader%2A> query can be formatted as in the following C# example:
|
||
|
|
||
|
```csharp
|
||
|
SqlCommand command = new SqlCommand("SELECT ContactID, FirstName, LastName FROM dbo.Contact FOR XML AUTO, XMLDATA", SqlConn);
|
||
|
```
|
||
|
|
||
|
This method can also be used to retrieve a single-row, single-column result set. In this case, if more than one row is returned, the `EndExecuteXmlReader` method attaches the <xref:System.Xml.XmlReader> to the value on the first row, and discards the rest of the result set.
|
||
|
|
||
|
The multiple active result set (MARS) feature lets multiple actions use the same connection.
|
||
|
|
||
|
Note that the command text and parameters are sent to the server synchronously. If a large command or many parameters are sent, this method may block during writes. After the command is sent, the method returns immediately without waiting for an answer from the server--that is, reads are asynchronous. Although command execution is asynchronous, value fetching is still synchronous.
|
||
|
|
||
|
Because this overload does not support a callback procedure, developers need to either poll to determine whether the command has completed, using the <xref:System.IAsyncResult.IsCompleted%2A> property of the <xref:System.IAsyncResult> returned by the <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteXmlReader%2A> method; or wait for the completion of one or more commands using the <xref:System.IAsyncResult.AsyncWaitHandle%2A> property of the returned <xref:System.IAsyncResult>.
|
||
|
|
||
|
If you use <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteReader%2A> or <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReader%2A> to access XML data, SQL Server returns any XML results greater than 2,033 characters in length in multiple rows of 2,033 characters each. To avoid this behavior, use <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteXmlReader%2A> or <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteXmlReader%2A> to read FOR XML queries.
|
||
|
|
||
|
This method ignores the <xref:Microsoft.Data.SqlClient.SqlCommand.CommandTimeout%2A> property.
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following console application starts the process of retrieving XML data asynchronously. While waiting for the results, this simple application sits in a loop, investigating the <xref:System.IAsyncResult.IsCompleted%2A> property value. Once the process has completed, the code retrieves the XML and displays its contents.
|
||
|
|
||
|
[!code-csharp[SqlCommand_BeginExecuteXmlReader#1]((~/../sqlclient/doc/samples/SqlCommand_BeginExecuteXmlReader.cs)]
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Binary** or **VarBinary** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Char**, **NChar**, **NVarChar**, **VarChar**, or **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
.
|
||
|
</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">
|
||
|
Any error that occurred while executing the command text.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A timeout occurred during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.InvalidOperationException">
|
||
|
The
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
closed or dropped during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
- or -
|
||
|
|
||
|
<see cref="P:Microssoft.Data.SqlClient.SqlCommand.EnableOptimizedParameterBinding" />
|
||
|
is set to true and a parameter with direction Output or InputOutput has been added to the <see cref="P:Microsoft.Data.SqlClient.SqlCommand.Parameters" /> collection.
|
||
|
</exception><exception cref="T:System.IO.IOException">
|
||
|
An error occurred in a
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.ObjectDisposedException">
|
||
|
The
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object was closed during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteXmlReader(System.AsyncCallback,System.Object)">
|
||
|
<param name="callback">
|
||
|
An
|
||
|
<see cref="T:System.AsyncCallback" />
|
||
|
delegate that is invoked when the command's execution has completed. Pass
|
||
|
<see langword="null" />
|
||
|
(
|
||
|
<see langword="Nothing" />
|
||
|
in Microsoft Visual Basic) to indicate that no callback is required.
|
||
|
</param><param name="stateObject">
|
||
|
A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback procedure using the
|
||
|
<see cref="P:System.IAsyncResult.AsyncState" />
|
||
|
property.
|
||
|
</param><summary>
|
||
|
Initiates the asynchronous execution of the Transact-SQL statement or stored procedure that is described by this
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlCommand" />
|
||
|
and returns results as an
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
object, using a callback procedure.
|
||
|
</summary><returns>
|
||
|
An
|
||
|
<see cref="T:System.IAsyncResult" />
|
||
|
that can be used to poll, wait for results, or both; this value is also needed when the
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.EndExecuteXmlReader(System.IAsyncResult)" />
|
||
|
is called, which returns the results of the command as XML.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteXmlReader%2A> method starts the process of asynchronously executing a Transact-SQL statement or stored procedure that returns rows as XML, so that other tasks can run concurrently while the statement is executing. When the statement has completed, developers must call the <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteXmlReader%2A> method to finish the operation and retrieve the requested XML data. The <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteXmlReader%2A> method returns immediately, but until the code executes the corresponding <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteXmlReader%2A> method call, it must not execute any other calls that start a synchronous or asynchronous execution against the same <xref:Microsoft.Data.SqlClient.SqlCommand> object. Calling the <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteXmlReader%2A> before the command's execution is completed causes the <xref:Microsoft.Data.SqlClient.SqlCommand> object to block until the execution is finished.
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlCommand.CommandText%2A> property ordinarily specifies a Transact-SQL statement with a valid FOR XML clause. However, `CommandText` can also specify a statement that returns data that contains valid XML. This method can also be used to retrieve a single-row, single-column result set. In this case, if more than one row is returned, the <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteXmlReader%2A> method attaches the <xref:System.Xml.XmlReader> to the value on the first row, and discards the rest of the result set.
|
||
|
|
||
|
A typical <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteXmlReader%2A> query can be formatted as in the following C# example:
|
||
|
|
||
|
```csharp
|
||
|
SqlCommand command = new SqlCommand("SELECT ContactID, FirstName, LastName FROM Contact FOR XML AUTO, XMLDATA", SqlConn);
|
||
|
```
|
||
|
|
||
|
This method can also be used to retrieve a single-row, single-column result set. In this case, if more than one row is returned, the <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteXmlReader%2A> method attaches the <xref:System.Xml.XmlReader> to the value on the first row, and discards the rest of the result set.
|
||
|
|
||
|
The multiple active result set (MARS) feature lets multiple actions use the same connection.
|
||
|
|
||
|
The `callback` parameter lets you specify an <xref:System.AsyncCallback> delegate that is called when the statement has completed. You can call the <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteXmlReader%2A> method from within this delegate procedure, or from any other location within your application. In addition, you can pass any object in the `stateObject` parameter, and your callback procedure can retrieve this information using the <xref:System.IAsyncResult.AsyncState%2A> property.
|
||
|
|
||
|
Note that the command text and parameters are sent to the server synchronously. If a large command or many parameters is sent, this method may block during writes. After the command is sent, the method returns immediately without waiting for an answer from the server--that is, reads are asynchronous.
|
||
|
|
||
|
All errors that occur during the execution of the operation are thrown as exceptions in the callback procedure. You must handle the exception in the callback procedure, not in the main application. See the example in this topic for additional information on handling exceptions in the callback procedure.
|
||
|
|
||
|
If you use <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteReader%2A> or <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReader%2A> to access XML data, SQL Server will return any XML results greater than 2,033 characters in length in multiple rows of 2,033 characters each. To avoid this behavior, use <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteXmlReader%2A> or <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteXmlReader%2A> to read FOR XML queries.
|
||
|
|
||
|
This method ignores the <xref:Microsoft.Data.SqlClient.SqlCommand.CommandTimeout%2A> property.
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following Windows application demonstrates the use of the <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteXmlReader%2A> method, executing a Transact-SQL statement that includes a delay of a few seconds (emulating a long-running command). This example passes the executing <xref:Microsoft.Data.SqlClient.SqlCommand> object as the `stateObject` parameter--doing so makes it simple to retrieve the <xref:Microsoft.Data.SqlClient.SqlCommand> object from within the callback procedure, so that the code can call the <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteXmlReader%2A> method corresponding to the initial call to <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteXmlReader%2A>.
|
||
|
|
||
|
This example demonstrates many important techniques. This includes calling a method that interacts with the form from a separate thread. In addition, this example demonstrates how you must block users from executing a command multiple times concurrently, and how you must make sure that the form does not close before the callback procedure is called.
|
||
|
|
||
|
To set up this example, create a new Windows application. Put a <xref:System.Windows.Forms.Button> control, a <xref:System.Windows.Forms.ListBox> control, and a <xref:System.Windows.Forms.Label> control on the form (accepting the default name for each control). Add the following code to the form's class, modifying the connection string as needed for your environment.
|
||
|
|
||
|
[!code-csharp[SqlCommand_BeginExecuteXmlReaderAsync](~/../sqlclient/doc/samples/SqlCommand_BeginExecuteXmlReaderAsync.cs)]
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Binary** or **VarBinary** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Char**, **NChar**, **NVarChar**, **VarChar**, or **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
.
|
||
|
</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">
|
||
|
Any error that occurred while executing the command text.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A timeout occurred during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.InvalidOperationException">
|
||
|
The
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
closed or dropped during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
- or -
|
||
|
|
||
|
<see cref="P:Microssoft.Data.SqlClient.SqlCommand.EnableOptimizedParameterBinding" />
|
||
|
is set to true and a parameter with direction Output or InputOutput has been added to the <see cref="P:Microsoft.Data.SqlClient.SqlCommand.Parameters" /> collection.
|
||
|
</exception><exception cref="T:System.IO.IOException">
|
||
|
An error occurred in a
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.ObjectDisposedException">
|
||
|
The
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object was closed during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><altmember cref="M:Microsoft.Data.SqlClient.SqlCommand.EndExecuteXmlReader(System.IAsyncResult)" /><altmember cref="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteXmlReader" />
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.Cancel">
|
||
|
<summary>
|
||
|
Tries to cancel the execution of a
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlCommand" />
|
||
|
.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
If there is nothing to cancel, nothing occurs. However, if there is a command in process, and the attempt to cancel fails, no exception is generated.
|
||
|
|
||
|
In some rare cases, if you call <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteReader%2A>, then call <xref:Microsoft.Data.SqlClient.SqlDataReader.Close%2A> (implicitly or explicitly) before calling <xref:Microsoft.Data.SqlClient.SqlCommand.Cancel%2A>, and then call <xref:Microsoft.Data.SqlClient.SqlCommand.Cancel%2A>, the cancel command will not be sent to SQL Server and the result set can continue to stream after you call <xref:Microsoft.Data.SqlClient.SqlConnection.Close%2A>. To avoid this, make sure that you call <xref:Microsoft.Data.SqlClient.SqlCommand.Cancel%2A> before closing the reader or connection.
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example demonstrates the use of the <xref:Microsoft.Data.SqlClient.SqlCommand.Cancel%2A> method.
|
||
|
|
||
|
[!code-csharp[SqlCommand_Cancel](~/../sqlclient/doc/samples/SqlCommand_Cancel.cs)]
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.Clone">
|
||
|
<summary>
|
||
|
Creates a new
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlCommand" />
|
||
|
object that is a copy of the current instance.
|
||
|
</summary><returns>
|
||
|
A new
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlCommand" />
|
||
|
object that is a copy of this instance.
|
||
|
</returns><remarks>
|
||
|
To be added.
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.CreateDbParameter">
|
||
|
<summary>
|
||
|
To be added.
|
||
|
</summary><returns>
|
||
|
To be added.
|
||
|
</returns><remarks>
|
||
|
To be added.
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.CreateParameter">
|
||
|
<summary>
|
||
|
Creates a new instance of a
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlParameter" />
|
||
|
object.
|
||
|
</summary><returns>
|
||
|
A
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlParameter" />
|
||
|
object.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlCommand.CreateParameter%2A> method is a strongly-typed version of <xref:System.Data.IDbCommand.CreateParameter%2A>.
|
||
|
]]></format>
|
||
|
</remarks><summary>
|
||
|
Creates a new instance of a <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> object.
|
||
|
</summary><returns>
|
||
|
A <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> object.
|
||
|
</returns><remarks>
|
||
|
To be added.
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.EndExecuteNonQuery(System.IAsyncResult)">
|
||
|
<param name="asyncResult">
|
||
|
The
|
||
|
<see cref="T:System.IAsyncResult" />
|
||
|
returned by the call to
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteNonQuery" />
|
||
|
.
|
||
|
</param><summary>
|
||
|
Finishes asynchronous execution of a Transact-SQL statement.
|
||
|
</summary><returns>
|
||
|
The number of rows affected (the same behavior as
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteNonQuery" />
|
||
|
).
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
When you call <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteNonQuery> to execute a Transact-SQL statement, you must call <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteNonQuery%2A> in order to complete the operation. If the process of executing the command has not yet finished, this method blocks until the operation is complete. Users can verify that the command has completed its operation by using the <xref:System.IAsyncResult> instance returned by the <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteNonQuery> method. If a callback procedure was specified in the call to <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteNonQuery>, this method must be called.
|
||
|
|
||
|
## Examples
|
||
|
For examples demonstrating the use of the <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteNonQuery%2A> method, see <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteNonQuery>.
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="asyncResult" />
|
||
|
parameter is null (
|
||
|
<see langword="Nothing" />
|
||
|
in Microsoft Visual Basic)
|
||
|
</exception><exception cref="T:System.InvalidOperationException">
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.EndExecuteNonQuery(System.IAsyncResult)" />
|
||
|
was called more than once for a single command execution, or the method was mismatched against its execution method (for example, the code called
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.EndExecuteNonQuery(System.IAsyncResult)" />
|
||
|
to complete execution of a call to
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteXmlReader" />
|
||
|
.
|
||
|
</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">
|
||
|
The amount of time specified in
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlCommand.CommandTimeout" />
|
||
|
elapsed and the asynchronous operation specified with
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteNonQuery" />
|
||
|
is not complete.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
In some situations,
|
||
|
<see cref="T:System.IAsyncResult" />
|
||
|
can be set to
|
||
|
<see langword="IsCompleted" />
|
||
|
incorrectly. If this occurs and
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.EndExecuteNonQuery(System.IAsyncResult)" />
|
||
|
is called, EndExecuteNonQuery could raise a SqlException error if the amount of time specified in
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlCommand.CommandTimeout" />
|
||
|
elapsed and the asynchronous operation specified with
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteNonQuery" />
|
||
|
is not complete. To correct this situation, you should either increase the value of CommandTimeout or reduce the work being done by the asynchronous operation.
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.EndExecuteReader(System.IAsyncResult)">
|
||
|
<param name="asyncResult">
|
||
|
The
|
||
|
<see cref="T:System.IAsyncResult" />
|
||
|
returned by the call to
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReader" />
|
||
|
.
|
||
|
</param><summary>
|
||
|
Finishes asynchronous execution of a Transact-SQL statement, returning the requested
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlDataReader" />
|
||
|
.
|
||
|
</summary><returns>
|
||
|
A
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlDataReader" />
|
||
|
object that can be used to retrieve the requested rows.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
When you call <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReader%2A> to execute a Transact-SQL statement, you must call <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteReader%2A> in order to complete the operation. If the process of executing the command has not yet finished, this method blocks until the operation is complete. Users can verify that the command has completed its operation by using the <xref:System.IAsyncResult> instance returned by the <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReader%2A> method. If a callback procedure was specified in the call to <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReader%2A>, this method must be called.
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
For examples demonstrating the use of the <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteReader%2A> method, see <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReader%2A>.
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="asyncResult" />
|
||
|
parameter is null (
|
||
|
<see langword="Nothing" />
|
||
|
in Microsoft Visual Basic)
|
||
|
</exception><exception cref="T:System.InvalidOperationException">
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.EndExecuteReader(System.IAsyncResult)" />
|
||
|
was called more than once for a single command execution, or the method was mismatched against its execution method (for example, the code called
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.EndExecuteReader(System.IAsyncResult)" />
|
||
|
to complete execution of a call to
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteXmlReader" />
|
||
|
.
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.EndExecuteXmlReader(System.IAsyncResult)">
|
||
|
<param name="asyncResult">
|
||
|
The
|
||
|
<see cref="T:System.IAsyncResult" />
|
||
|
returned by the call to
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteXmlReader" />
|
||
|
.
|
||
|
</param><summary>
|
||
|
Finishes asynchronous execution of a Transact-SQL statement, returning the requested data as XML.
|
||
|
</summary><returns>
|
||
|
An
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
object that can be used to fetch the resulting XML data.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
When you call <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteXmlReader%2A> to execute a Transact-SQL statement, you must call <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteXmlReader%2A> in order to complete the operation. If the process of executing the command has not yet finished, this method blocks until the operation is complete. Users can verify that the command has completed its operation by using the <xref:System.IAsyncResult> instance returned by the <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteXmlReader%2A> method. If a callback procedure was specified in the call to <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteXmlReader%2A>, this method must be called.
|
||
|
|
||
|
## Examples
|
||
|
For examples demonstrating the use of the <xref:Microsoft.Data.SqlClient.SqlCommand.EndExecuteXmlReader%2A> method, see <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteXmlReader%2A>.
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="asyncResult" />
|
||
|
parameter is null (
|
||
|
<see langword="Nothing" />
|
||
|
in Microsoft Visual Basic)
|
||
|
</exception><exception cref="T:System.InvalidOperationException">
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.EndExecuteXmlReader(System.IAsyncResult)" />
|
||
|
was called more than once for a single command execution, or the method was mismatched against its execution method (for example, the code called
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.EndExecuteXmlReader(System.IAsyncResult)" />
|
||
|
to complete execution of a call to
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteNonQuery" />
|
||
|
.
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteDbDataReader(System.Data.CommandBehavior)">
|
||
|
<param name="behavior">
|
||
|
To be added.
|
||
|
</param><summary>
|
||
|
To be added.
|
||
|
</summary><returns>
|
||
|
To be added.
|
||
|
</returns><remarks>
|
||
|
To be added.
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteDbDataReaderAsync(System.Data.CommandBehavior,System.Threading.CancellationToken)">
|
||
|
<param name="behavior">
|
||
|
To be added.
|
||
|
</param><param name="cancellationToken">
|
||
|
To be added.
|
||
|
</param><summary>
|
||
|
To be added.
|
||
|
</summary><returns>
|
||
|
To be added.
|
||
|
</returns><remarks>
|
||
|
To be added.
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteNonQuery">
|
||
|
<summary>
|
||
|
Executes a Transact-SQL statement against the connection and returns the number of rows affected.
|
||
|
</summary><returns>
|
||
|
The number of rows affected.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
You can use the <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteNonQuery%2A> to perform catalog operations (for example, querying the structure of a database or creating database objects such as tables), or to change the data in a database without using a <xref:System.Data.DataSet> by executing UPDATE, INSERT, or DELETE statements.
|
||
|
|
||
|
Although the <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteNonQuery%2A> returns no rows, any output parameters or return values mapped to parameters are populated with data.
|
||
|
|
||
|
For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. For all other types of statements, the return value is -1.
|
||
|
When a trigger exists on a table being inserted or updated, the return value includes the number of rows affected by both the insert or update operation and the number of rows affected by the trigger or triggers.
|
||
|
When SET NOCOUNT ON is set on the connection (before or as part of executing the command, or as part of a trigger initiated by the execution of the command) the rows affected by individual statements stop contributing to the count of rows affected that is returned by this method.
|
||
|
If no statements are detected that contribute to the count, the return value is -1. If a rollback occurs, the return value is also -1.
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlCommand> and then executes it using <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteNonQuery%2A>. The example is passed a string that is a Transact-SQL statement (such as UPDATE, INSERT, or DELETE) and a string to use to connect to the data source.
|
||
|
|
||
|
[!code-csharp[SqlCommand_ExecuteNonQuery](~/../sqlclient/doc/samples/SqlCommand_ExecuteNonQuery.cs)]
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Binary** or **VarBinary** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Char**, **NChar**, **NVarChar**, **VarChar**, or **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
.
|
||
|
</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">
|
||
|
An exception occurred while executing the command against a locked row. This exception is not generated when you are using Microsoft .NET Framework version 1.0.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A timeout occurred during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.IO.IOException">
|
||
|
An error occurred in a
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.InvalidOperationException">
|
||
|
The
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
closed or dropped during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.ObjectDisposedException">
|
||
|
The
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object was closed during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteNonQueryAsync(System.Threading.CancellationToken)">
|
||
|
<param name="cancellationToken">
|
||
|
The cancellation instruction.
|
||
|
</param><summary>
|
||
|
An asynchronous version of
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteNonQuery" />
|
||
|
, which executes a Transact-SQL statement against the connection and returns the number of rows affected. The cancellation token can be used to request that the operation be abandoned before the command timeout elapses. Exceptions will be reported via the returned Task object.
|
||
|
</summary><returns>
|
||
|
A task representing the asynchronous operation.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see [Asynchronous Programming](/sql/connect/ado-net/asynchronous-programming).
|
||
|
|
||
|
> [!NOTE]
|
||
|
> For long running queries on the server, consider using <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteNonQuery%2A> due to a known issue with canceling queries via a cancellation token. Also, consider canceling execution using the <xref:Microsoft.Data.SqlClient.SqlCommand.Cancel%2A> method.
|
||
|
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Binary** or **VarBinary** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Char**, **NChar**, **NVarChar**, **VarChar**, or **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
.
|
||
|
</exception><exception cref="T:System.InvalidOperationException">
|
||
|
Calling
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteNonQueryAsync(System.Threading.CancellationToken)" />
|
||
|
more than once for the same instance before task completion.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
The
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
closed or dropped during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">
|
||
|
SQL Server returned an error while executing the command text.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A timeout occurred during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.IO.IOException">
|
||
|
An error occurred in a
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.ObjectDisposedException">
|
||
|
The
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object was closed during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteReader">
|
||
|
<summary>
|
||
|
Sends the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlCommand.CommandText" />
|
||
|
to the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlCommand.Connection" />
|
||
|
and builds a
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlDataReader" />
|
||
|
.
|
||
|
</summary><returns>
|
||
|
A
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlDataReader" />
|
||
|
object.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
When the <xref:Microsoft.Data.SqlClient.SqlCommand.CommandType%2A> property is set to `StoredProcedure`, the <xref:Microsoft.Data.SqlClient.SqlCommand.CommandText%2A> property should be set to the name of the stored procedure. The command executes this stored procedure when you call <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteReader%2A>.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> If a transaction is deadlocked, an exception may not be thrown until <xref:Microsoft.Data.SqlClient.SqlDataReader.Read%2A> is called.
|
||
|
|
||
|
The multiple active result set (MARS) feature allows for multiple actions using the same connection.
|
||
|
|
||
|
If you use <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteReader%2A> or <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReader%2A> to access XML data, SQL Server will return any XML results greater than 2,033 characters in length in multiple rows of 2,033 characters each. To avoid this behavior, use <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteXmlReader%2A> or <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteXmlReader%2A> to read FOR XML queries.
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlCommand>, and then executes it by passing a string that is a Transact-SQL SELECT statement, and a string to use to connect to the data source.
|
||
|
|
||
|
[!code-csharp[SqlCommand_ExecuteReader](~/../sqlclient/doc/samples/SqlCommand_ExecuteReader.cs)]
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Binary** or **VarBinary** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Char**, **NChar**, **NVarChar**, **VarChar**, or **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
.
|
||
|
</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">
|
||
|
An exception occurred while executing the command against a locked row. This exception is not generated when you are using Microsoft .NET Framework version 1.0.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A timeout occurred during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.InvalidOperationException">
|
||
|
The current state of the connection is closed.
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteReader" />
|
||
|
requires an open
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
The
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
closed or dropped during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.IO.IOException">
|
||
|
An error occurred in a
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.ObjectDisposedException">
|
||
|
The
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object was closed during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteReader(System.Data.CommandBehavior)">
|
||
|
<param name="behavior">
|
||
|
One of the
|
||
|
<see cref="T:System.Data.CommandBehavior" />
|
||
|
values.
|
||
|
</param><summary>
|
||
|
Sends the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlCommand.CommandText" />
|
||
|
to the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlCommand.Connection" />
|
||
|
, and builds a
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlDataReader" />
|
||
|
using one of the
|
||
|
<see cref="T:System.Data.CommandBehavior" />
|
||
|
values.
|
||
|
</summary><returns>
|
||
|
A
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlDataReader" />
|
||
|
object.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
When the <xref:Microsoft.Data.SqlClient.SqlCommand.CommandType%2A> property is set to `StoredProcedure`, the <xref:Microsoft.Data.SqlClient.SqlCommand.CommandText%2A> property should be set to the name of the stored procedure. The command executes this stored procedure when you call <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteReader%2A>.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> Use <xref:System.Data.CommandBehavior.SequentialAccess> to retrieve large values and binary data. Otherwise, an <xref:System.OutOfMemoryException> might occur and the connection will be closed.
|
||
|
|
||
|
The multiple active result set (MARS) feature allows for multiple actions using the same connection.
|
||
|
|
||
|
If you use <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteReader%2A> or <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReader%2A> to access XML data, SQL Server will return any XML results greater than 2,033 characters in length in multiple rows of 2,033 characters each. To avoid this behavior, use <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteXmlReader%2A> or <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteXmlReader%2A> to read FOR XML queries.
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlCommand>, and then executes it by passing a string that is a Transact-SQL SELECT statement, and a string to use to connect to the data source. <xref:System.Data.CommandBehavior> is set to <xref:System.Data.CommandBehavior.CloseConnection>.
|
||
|
|
||
|
[!code-csharp[SqlCommand_ExecuteReader2](~/../sqlclient/doc/samples/SqlCommand_ExecuteReader2.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Binary** or **VarBinary** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Char**, **NChar**, **NVarChar**, **VarChar**, or **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
.
|
||
|
</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">
|
||
|
A timeout occurred during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.IO.IOException">
|
||
|
An error occurred in a
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.InvalidOperationException">
|
||
|
The
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
closed or dropped during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.ObjectDisposedException">
|
||
|
The
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object was closed during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteReaderAsync">
|
||
|
<summary>
|
||
|
An asynchronous version of
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteReader" />
|
||
|
, which sends the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlCommand.CommandText" />
|
||
|
to the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlCommand.Connection" />
|
||
|
and builds a
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlDataReader" />
|
||
|
. Exceptions will be reported via the returned Task object.
|
||
|
</summary><returns>
|
||
|
A task representing the asynchronous operation.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see [Asynchronous Programming](/sql/connect/ado-net/asynchronous-programming).
|
||
|
|
||
|
> [!NOTE]
|
||
|
> For long running queries on the server, consider using <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteReader%2A> due to a known issue with canceling queries via a cancellation token. Also, consider canceling execution using the <xref:Microsoft.Data.SqlClient.SqlCommand.Cancel%2A> method.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Binary** or **VarBinary** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Char**, **NChar**, **NVarChar**, **VarChar**, or **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
.
|
||
|
</exception><exception cref="T:System.ArgumentException">
|
||
|
An invalid
|
||
|
<see cref="T:System.Data.CommandBehavior" />
|
||
|
value.
|
||
|
</exception><exception cref="T:System.InvalidOperationException">
|
||
|
Calling
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteReaderAsync" />
|
||
|
more than once for the same instance before task completion.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
The
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
closed or dropped during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">
|
||
|
SQL Server returned an error while executing the command text.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A timeout occurred during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.IO.IOException">
|
||
|
An error occurred in a
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.ObjectDisposedException">
|
||
|
The
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object was closed during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteReaderAsync(System.Data.CommandBehavior)">
|
||
|
<param name="behavior">
|
||
|
Options for statement execution and data retrieval. When is set to
|
||
|
<see langword="Default" />
|
||
|
,
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlDataReader.ReadAsync(System.Threading.CancellationToken)" />
|
||
|
reads the entire row before returning a complete Task.
|
||
|
</param><summary>
|
||
|
An asynchronous version of
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteReader(System.Data.CommandBehavior)" />
|
||
|
, which sends the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlCommand.CommandText" />
|
||
|
to the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlCommand.Connection" />
|
||
|
, and builds a
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlDataReader" />
|
||
|
. Exceptions will be reported via the returned Task object.
|
||
|
</summary><returns>
|
||
|
A task representing the asynchronous operation.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see [Asynchronous Programming](/sql/connect/ado-net/asynchronous-programming).
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Binary** or **VarBinary** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Char**, **NChar**, **NVarChar**, **VarChar**, or **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
.
|
||
|
</exception><exception cref="T:System.ArgumentException">
|
||
|
An invalid
|
||
|
<see cref="T:System.Data.CommandBehavior" />
|
||
|
value.
|
||
|
</exception><exception cref="T:System.InvalidOperationException">
|
||
|
Calling
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteReaderAsync(System.Data.CommandBehavior)" />
|
||
|
more than once for the same instance before task completion.
|
||
|
|
||
|
-or-
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
closed or dropped during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">
|
||
|
SQL Server returned an error while executing the command text.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A timeout occurred during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.IO.IOException">
|
||
|
An error occurred in a
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.ObjectDisposedException">
|
||
|
The
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object was closed during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteReaderAsync(System.Data.CommandBehavior,System.Threading.CancellationToken)">
|
||
|
<param name="behavior">
|
||
|
Options for statement execution and data retrieval. When is set to
|
||
|
<see langword="Default" />
|
||
|
,
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlDataReader.ReadAsync(System.Threading.CancellationToken)" />
|
||
|
reads the entire row before returning a complete Task.
|
||
|
</param><param name="cancellationToken">
|
||
|
The cancellation instruction.
|
||
|
</param><summary>
|
||
|
An asynchronous version of
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteReader(System.Data.CommandBehavior)" />
|
||
|
, which sends the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlCommand.CommandText" />
|
||
|
to the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlCommand.Connection" />
|
||
|
, and builds a
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlDataReader" />
|
||
|
The cancellation token can be used to request that the operation be abandoned before the command timeout elapses. Exceptions will be reported via the returned Task object.
|
||
|
</summary><returns>
|
||
|
A task representing the asynchronous operation.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see [Asynchronous Programming](/sql/connect/ado-net/asynchronous-programming).
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Binary** or **VarBinary** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Char**, **NChar**, **NVarChar**, **VarChar**, or **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
.
|
||
|
</exception><exception cref="T:System.ArgumentException">
|
||
|
An invalid
|
||
|
<see cref="T:System.Data.CommandBehavior" />
|
||
|
value.
|
||
|
</exception><exception cref="T:System.InvalidOperationException">
|
||
|
Calling
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteReaderAsync(System.Data.CommandBehavior,System.Threading.CancellationToken)" />
|
||
|
more than once for the same instance before task completion.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
The
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
closed or dropped during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">
|
||
|
SQL Server returned an error while executing the command text.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A timeout occurred during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.IO.IOException">
|
||
|
An error occurred in a
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.ObjectDisposedException">
|
||
|
The
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object was closed during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteReaderAsync(System.Threading.CancellationToken)">
|
||
|
<param name="cancellationToken">
|
||
|
The cancellation instruction.
|
||
|
</param><summary>
|
||
|
An asynchronous version of
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteReader" />
|
||
|
, which sends the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlCommand.CommandText" />
|
||
|
to the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlCommand.Connection" />
|
||
|
and builds a
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlDataReader" />
|
||
|
.
|
||
|
|
||
|
The cancellation token can be used to request that the operation be abandoned before the command timeout elapses. Exceptions will be reported via the returned Task object.
|
||
|
</summary><returns>
|
||
|
A task representing the asynchronous operation.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown">
|
||
|
<![CDATA[
|
||
|
## Remarks
|
||
|
For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see [Asynchronous Programming](/sql/connect/ado-net/asynchronous-programming).
|
||
|
]]>
|
||
|
</format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Binary** or **VarBinary** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Char**, **NChar**, **NVarChar**, **VarChar**, or **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
.
|
||
|
</exception><exception cref="T:System.ArgumentException">
|
||
|
An invalid
|
||
|
<see cref="T:System.Data.CommandBehavior" />
|
||
|
value.
|
||
|
</exception><exception cref="T:System.InvalidOperationException">
|
||
|
Calling
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteReaderAsync(System.Data.CommandBehavior,System.Threading.CancellationToken)" />
|
||
|
more than once for the same instance before task completion.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
The
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
closed or dropped during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">
|
||
|
SQL Server returned an error while executing the command text.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A timeout occurred during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.IO.IOException">
|
||
|
An error occurred in a
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.ObjectDisposedException">
|
||
|
The
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object was closed during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteScalar">
|
||
|
<summary>
|
||
|
Executes the query, and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored.
|
||
|
</summary><returns>
|
||
|
The first column of the first row in the result set, or a null reference (
|
||
|
<see langword="Nothing" />
|
||
|
in Visual Basic) if the result set is empty. Returns a maximum of 2033 characters.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Use the <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteScalar%2A> method to retrieve a single value (for example, an aggregate value) from a database. This requires less code than using the <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteReader%2A> method, and then performing the operations that you need to generate the single value using the data returned by a <xref:Microsoft.Data.SqlClient.SqlDataReader>.
|
||
|
|
||
|
A typical <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteScalar%2A> query can be formatted as in the following C# example:
|
||
|
|
||
|
```csharp
|
||
|
cmd.CommandText = "SELECT COUNT(*) FROM dbo.region";
|
||
|
Int32 count = (Int32) cmd.ExecuteScalar();
|
||
|
```
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlCommand> and then executes it using <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteScalar%2A>. The example is passed a string representing a new value to be inserted into a table, and a string to use to connect to the data source. The function returns the new **Identity** column value if a new row was inserted, 0 on failure.
|
||
|
|
||
|
[!code-csharp[SqlCommand.ExecuteScalar#1](~/../sqlclient/doc/samples/SqlCommand_ExecuteScalar.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Binary** or **VarBinary** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Char**, **NChar**, **NVarChar**, **VarChar**, or **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
.
|
||
|
</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">
|
||
|
An exception occurred while executing the command against a locked row. This exception is not generated when you are using Microsoft .NET Framework version 1.0.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A timeout occurred during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.InvalidOperationException">
|
||
|
The
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
closed or dropped during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.IO.IOException">
|
||
|
An error occurred in a
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.ObjectDisposedException">
|
||
|
The
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object was closed during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteScalarAsync(System.Threading.CancellationToken)">
|
||
|
<param name="cancellationToken">
|
||
|
The cancellation instruction.
|
||
|
</param><summary>
|
||
|
An asynchronous version of
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteScalar" />
|
||
|
, which executes the query asynchronously and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored.
|
||
|
|
||
|
The cancellation token can be used to request that the operation be abandoned before the command timeout elapses. Exceptions will be reported via the returned Task object.
|
||
|
</summary><returns>
|
||
|
A task representing the asynchronous operation.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see [Asynchronous Programming](/sql/connect/ado-net/asynchronous-programming).
|
||
|
|
||
|
> [!NOTE]
|
||
|
> For long running queries on the server, consider using <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteScalar%2A> due to a known issue with canceling queries via a cancellation token. Also, consider canceling execution using the <xref:Microsoft.Data.SqlClient.SqlCommand.Cancel%2A> method.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Binary** or **VarBinary** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Char**, **NChar**, **NVarChar**, **VarChar**, or **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
.
|
||
|
</exception><exception cref="T:System.InvalidOperationException">
|
||
|
Calling
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteScalarAsync(System.Threading.CancellationToken)" />
|
||
|
more than once for the same instance before task completion.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
The
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
closed or dropped during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">
|
||
|
SQL Server returned an error while executing the command text.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A timeout occurred during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.IO.IOException">
|
||
|
An error occurred in a
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.ObjectDisposedException">
|
||
|
The
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object was closed during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteXmlReader">
|
||
|
<summary>
|
||
|
Sends the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlCommand.CommandText" />
|
||
|
to the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlCommand.Connection" />
|
||
|
and builds an
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
object.
|
||
|
</summary><returns>
|
||
|
An
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
object.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The **XmlReader** returned by this method does not support asynchronous operations.
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlCommand.CommandText%2A> property ordinarily specifies a Transact-SQL statement with a valid FOR XML clause. However, <xref:Microsoft.Data.SqlClient.SqlCommand.CommandText%2A> can also specify a statement that returns `ntext` or `nvarchar` data that contains valid XML, or the contents of a column defined with the `xml` data type.
|
||
|
|
||
|
A typical <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteXmlReader%2A> query can be formatted as in the following Microsoft Visual C# example:
|
||
|
|
||
|
```csharp
|
||
|
SqlCommand command = new SqlCommand("SELECT * FROM dbo.Customers FOR XML AUTO, XMLDATA", SqlConn);
|
||
|
```
|
||
|
|
||
|
This method can also be used to retrieve a single-row, single-column result set that contains XML data. In this case, if more than one row is returned, the <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteXmlReader%2A> method attaches the <xref:System.Xml.XmlReader> to the value on the first row, and discards the rest of the result set.
|
||
|
|
||
|
The multiple active result set (MARS) feature allows for multiple actions using the same connection.
|
||
|
|
||
|
If you use <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteReader%2A> or <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteReader%2A> to access XML data, SQL Server will return any XML results greater than 2,033 characters in length in multiple rows of 2,033 characters each. To avoid this behavior, use <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteXmlReader%2A> or <xref:Microsoft.Data.SqlClient.SqlCommand.BeginExecuteXmlReader%2A> to read FOR XML queries.
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlCommand> and then executes it using <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteXmlReader%2A>. The example is passed a string that is a Transact-SQL FOR XML SELECT statement, and a string to use to connect to the data source.
|
||
|
|
||
|
[!code-csharp[SqlCommand_ExecuteXmlReader#1](~/../sqlclient/doc/samples/SqlCommand_ExecuteXmlReader.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Binary** or **VarBinary** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Char**, **NChar**, **NVarChar**, **VarChar**, or **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
.
|
||
|
</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">
|
||
|
An exception occurred while executing the command against a locked row. This exception is not generated when you are using Microsoft .NET Framework version 1.0.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A timeout occurred during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.InvalidOperationException">
|
||
|
The
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
closed or dropped during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.IO.IOException">
|
||
|
An error occurred in a
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.ObjectDisposedException">
|
||
|
The
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object was closed during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteXmlReaderAsync">
|
||
|
<summary>
|
||
|
An asynchronous version of
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteXmlReader" />
|
||
|
, which sends the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlCommand.CommandText" />
|
||
|
to the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlCommand.Connection" />
|
||
|
and builds an
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
object.
|
||
|
|
||
|
Exceptions will be reported via the returned Task object.
|
||
|
</summary><returns>
|
||
|
A task representing the asynchronous operation.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The **XmlReader** returned by this method does not support asynchronous operations.
|
||
|
For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see [Asynchronous Programming](/sql/connect/ado-net/asynchronous-programming).
|
||
|
|
||
|
> [!NOTE]
|
||
|
> For long running queries on the server, consider using <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteXmlReader%2A> due to a known issue with canceling queries via a cancellation token. Also, consider canceling execution using the <xref:Microsoft.Data.SqlClient.SqlCommand.Cancel%2A> method.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Binary** or **VarBinary** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Char**, **NChar**, **NVarChar**, **VarChar**, or **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
.
|
||
|
</exception><exception cref="T:System.InvalidOperationException">
|
||
|
Calling
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteScalarAsync(System.Threading.CancellationToken)" />
|
||
|
more than once for the same instance before task completion.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
The
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
closed or dropped during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">
|
||
|
SQL Server returned an error while executing the command text.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A timeout occurred during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.IO.IOException">
|
||
|
An error occurred in a
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.ObjectDisposedException">
|
||
|
The
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object was closed during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteXmlReaderAsync(System.Threading.CancellationToken)">
|
||
|
<param name="cancellationToken">
|
||
|
The cancellation instruction.
|
||
|
</param><summary>
|
||
|
An asynchronous version of
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteXmlReader" />
|
||
|
, which sends the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlCommand.CommandText" />
|
||
|
to the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlCommand.Connection" />
|
||
|
and builds an
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
object.
|
||
|
|
||
|
The cancellation token can be used to request that the operation be abandoned before the command timeout elapses. Exceptions will be reported via the returned Task object.
|
||
|
</summary><returns>
|
||
|
A task representing the asynchronous operation.
|
||
|
</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The **XmlReader** returned by this method does not support asynchronous operations.
|
||
|
For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see [Asynchronous Programming](/sql/connect/ado-net/asynchronous-programming).
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Binary** or **VarBinary** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Char**, **NChar**, **NVarChar**, **VarChar**, or **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType" />
|
||
|
other than **Xml** was used when
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />
|
||
|
was set to
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
.
|
||
|
</exception><exception cref="T:System.InvalidOperationException">
|
||
|
Calling
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteScalarAsync(System.Threading.CancellationToken)" />
|
||
|
more than once for the same instance before task completion.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
The
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
closed or dropped during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">
|
||
|
SQL Server returned an error while executing the command text.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A timeout occurred during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.IO.IOException">
|
||
|
An error occurred in a
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception><exception cref="T:System.ObjectDisposedException">
|
||
|
The
|
||
|
<see cref="T:System.IO.Stream" />
|
||
|
,
|
||
|
<see cref="T:System.Xml.XmlReader" />
|
||
|
or
|
||
|
<see cref="T:System.IO.TextReader" />
|
||
|
object was closed during a streaming operation. For more information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.Prepare">
|
||
|
<summary>
|
||
|
Creates a prepared version of the command on an instance of SQL Server.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
If <xref:Microsoft.Data.SqlClient.SqlCommand.CommandType%2A> is set to `StoredProcedure`, the call to <xref:Microsoft.Data.SqlClient.SqlCommand.Prepare%2A> should succeed, although it may cause a no-op.
|
||
|
|
||
|
Before you call <xref:Microsoft.Data.SqlClient.SqlCommand.Prepare%2A>, specify the data type of each parameter in the statement to be prepared. For each parameter that has a variable length data type, you must set the <xref:Microsoft.Data.SqlClient.SqlParameter.Size%2A> property to the maximum size needed. <xref:Microsoft.Data.SqlClient.SqlCommand.Prepare%2A> returns an error if these conditions are not met.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> If the database context is changed by executing the Transact-SQL `USE <database>` statement, or by calling the <xref:Microsoft.Data.SqlClient.SqlConnection.ChangeDatabase%2A> method, then <xref:Microsoft.Data.SqlClient.SqlCommand.Prepare%2A> must be called a second time.
|
||
|
|
||
|
If you call an `Execute` method after calling <xref:Microsoft.Data.SqlClient.SqlCommand.Prepare%2A>, any parameter value that is larger than the value specified by the <xref:Microsoft.Data.SqlClient.SqlParameter.Size%2A> property is automatically truncated to the original specified size of the parameter, and no truncation errors are returned.
|
||
|
|
||
|
Output parameters (whether prepared or not) must have a user-specified data type. If you specify a variable length data type, you must also specify the maximum <xref:Microsoft.Data.SqlClient.SqlParameter.Size%2A>.
|
||
|
|
||
|
Prior to Visual Studio 2010, <xref:Microsoft.Data.SqlClient.SqlCommand.Prepare%2A> threw an exception. Beginning in Visual Studio 2010, this method does not throw an exception.
|
||
|
|
||
|
## Examples
|
||
|
The following example demonstrates the use of the <xref:Microsoft.Data.SqlClient.SqlCommand.Prepare%2A> method.
|
||
|
|
||
|
[!code-csharp[SqlCommand.Prepare#1](~/../sqlclient/doc/samples/SqlCommand_Prepare.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlCommand.Notification">
|
||
|
<summary>
|
||
|
Gets or sets a value that specifies the
|
||
|
<see cref="T:Microsoft.Data.Sql.SqlNotificationRequest" />
|
||
|
object bound to this command.
|
||
|
</summary><value>
|
||
|
When set to null (default), no notification should be requested.
|
||
|
</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
You must set the value for this property before the command is executed for it to take effect.
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.RegisterColumnEncryptionKeyStoreProvidersOnCommand(System.Collections.Generic.IDictionary{System.String,Microsoft.Data.SqlClient.SqlColumnEncryptionKeyStoreProvider})">
|
||
|
<param name="customProviders">Dictionary of custom column encryption key providers</param><summary>Registers the encryption key store providers on the <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> instance. If this function has been called, any providers registered using the <see cref="M:Microsoft.Data.SqlClient.SqlConnection.RegisterColumnEncryptionKeyStoreProviders(System.Collections.Generic.IDictionary{System.String,Microsoft.Data.SqlClient.SqlColumnEncryptionKeyStoreProvider})" /> or
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlConnection.RegisterColumnEncryptionKeyStoreProvidersOnConnection(System.Collections.Generic.IDictionary{System.String,Microsoft.Data.SqlClient.SqlColumnEncryptionKeyStoreProvider})" /> methods will be ignored. This function can be called more than once. This does shallow copying of the dictionary so that the app cannot alter the custom provider list once it has been set.</summary><exception cref="T:System.ArgumentNullException">
|
||
|
A null dictionary was provided.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A string key in the dictionary was null or empty.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A <see cref="T:Microsoft.Data.SqlClient.SqlColumnEncryptionKeyStoreProvider" /> value in the dictionary was null.
|
||
|
</exception><exception cref="T:System.ArgumentException">
|
||
|
A string key in the dictionary started with "MSSQL_". This prefix is reserved for system providers.
|
||
|
</exception><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
## Remarks
|
||
|
Custom master key store providers can be registered with the driver at three different layers. The precedence of the three registrations is as follows:
|
||
|
|
||
|
- The per-command registration will be checked if it is not empty.
|
||
|
- If the per-command registration is empty, the per-connection registration will be checked if it is not empty.
|
||
|
- If the per-connection registration is empty, the global registration will be checked.
|
||
|
|
||
|
Once any key store provider is found at a registration level, the driver will **NOT** fall back to the other registrations to search for a provider. If providers are registered but the proper provider is not found at a level, an exception will be thrown containing only the registered providers in the registration that was checked.
|
||
|
|
||
|
The built-in column master key store providers that are available for the Windows Certificate Store, CNG Store and CSP are pre-registered.
|
||
|
|
||
|
This does shallow copying of the dictionary so that the app cannot alter the custom provider list once it has been set.
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.ResetCommandTimeout">
|
||
|
<summary> Resets the <see cref="P:Microsoft.Data.SqlClient.SqlCommand.CommandTimeout" /> property to its default value.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The default value of the <xref:Microsoft.Data.SqlClient.SqlCommand.CommandTimeout%2A> is 30 seconds.
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlCommand.RetryLogicProvider">
|
||
|
<summary>
|
||
|
Gets or sets a value that specifies the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlRetryLogicBaseProvider" />
|
||
|
object bound to this command.
|
||
|
</summary><value>
|
||
|
When set to null (default), the default non-retriable provider will be used.
|
||
|
</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
You must set the value for this property before the command is executed for it to take effect.
|
||
|
|
||
|
To apply the retry logic, do the following steps before executing the command:
|
||
|
1. Define the configuration parameters by using <xref:Microsoft.Data.SqlClient.SqlRetryLogicOption> type.
|
||
|
2. Create a <xref:Microsoft.Data.SqlClient.SqlRetryLogicBaseProvider> by using one of the following static methods of the <xref:Microsoft.Data.SqlClient.SqlConfigurableRetryFactory> class:
|
||
|
- <xref:Microsoft.Data.SqlClient.SqlConfigurableRetryFactory.CreateFixedRetryProvider%2A>
|
||
|
- <xref:Microsoft.Data.SqlClient.SqlConfigurableRetryFactory.CreateIncrementalRetryProvider%2A>
|
||
|
- <xref:Microsoft.Data.SqlClient.SqlConfigurableRetryFactory.CreateExponentialRetryProvider%2A>
|
||
|
- <xref:Microsoft.Data.SqlClient.SqlConfigurableRetryFactory.CreateNoneRetryProvider%2A>
|
||
|
3. Assign the <xref:Microsoft.Data.SqlClient.SqlRetryLogicBaseProvider> object to the `RetryLogicProvider` property.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> Detecting retriable exceptions is a vital part of the retry pattern. Before applying retry logic, it is important to investigate exceptions and choose a retry provider that best fits your scenario. First, log your exceptions and find transient faults.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> The command **timeout** restarts for each execution of a command within the retry logic and after applying the retry time delay. There is no timing overlap between these two actions.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> The default retry logic provider is not enabled unless it is configured in an application configuration file. For more information, see [Configurable retry logic configuration file](/sql/connect/ado-net/configurable-retry-logic-config-file-sqlclient).
|
||
|
|
||
|
> [!CAUTION]
|
||
|
> A command with <xref:System.Data.CommandBehavior.CloseConnection?displayProperty=nameWithType> isn't compatible with the built-in retry logic. The underlying connection is immediately closed after the first execution attempt and is no longer available for subsequent retries.
|
||
|
|
||
|
## Example
|
||
|
The following sample creates a database and establishes an active connection to it. While the database has an active connection, it tries to drop it with a new <xref:Microsoft.Data.SqlClient.SqlConnection> and a <xref:Microsoft.Data.SqlClient.SqlCommand> that uses a <xref:Microsoft.Data.SqlClient.SqlRetryLogicBaseProvider>. You should kill the active connection through the database to unblock the second command before exceeding the number of retries.
|
||
|
The blocking connection simulates a situation like a command still running in the database and unlikely to finish.
|
||
|
|
||
|
[!code-csharp[SqlConfigurableRetryLogic_SqlCommand#1](~/../sqlclient/doc/samples/SqlConfigurableRetryLogic_SqlCommand.cs#1)]
|
||
|
|
||
|
### How to use with synchronous commands
|
||
|
|
||
|
[!code-csharp[SqlConfigurableRetryLogic_SqlCommand#2](~/../sqlclient/doc/samples/SqlConfigurableRetryLogic_SqlCommand.cs#2)]
|
||
|
|
||
|
### How to use with asynchoronous commands
|
||
|
|
||
|
[!code-csharp[SqlConfigurableRetryLogic_SqlCommand#3](~/../sqlclient/doc/samples/SqlConfigurableRetryLogic_SqlCommand.cs#3)]
|
||
|
|
||
|
### How to use with legacy asynchronous commands
|
||
|
Besides assigning the provider to the command and executing the command, it's possible to run it directly using the following <xref:Microsoft.Data.SqlClient.SqlRetryLogicBaseProvider> methods:
|
||
|
- <xref:Microsoft.Data.SqlClient.SqlRetryLogicBaseProvider.Execute%60%601(System.Object,System.Func{%60%600})>
|
||
|
- <xref:Microsoft.Data.SqlClient.SqlRetryLogicBaseProvider.ExecuteAsync(System.Object,System.Func{System.Threading.Tasks.Task},System.Threading.CancellationToken)>
|
||
|
- <xref:Microsoft.Data.SqlClient.SqlRetryLogicBaseProvider.ExecuteAsync%60%601(System.Object,System.Func{System.Threading.Tasks.Task{%60%600}},System.Threading.CancellationToken)>
|
||
|
|
||
|
[!code-csharp[SqlConfigurableRetryLogic_SqlCommand#4](~/../sqlclient/doc/samples/SqlConfigurableRetryLogic_SqlCommand.cs#4)]
|
||
|
|
||
|
> [!NOTE]
|
||
|
> The Asynchronous Programming Model (APM) is a legacy pattern that uses a pair of methods starting with `Begin` and `End`, and an interface called `IAsyncResult`. It's not recommended to use this pattern in new applications. These methods are for backwards compatibility.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommand.Dispose(System.Boolean)">
|
||
|
<param name="disposing">
|
||
|
To be added.
|
||
|
</param><summary>
|
||
|
To be added.
|
||
|
</summary><remarks>
|
||
|
To be added.
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlCommandBuilder">
|
||
|
<summary>
|
||
|
Automatically generates single-table commands that are used to reconcile changes made to a
|
||
|
<see cref="T:System.Data.DataSet" />
|
||
|
with the associated SQL Server database. This class cannot be inherited.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlDataAdapter> does not automatically generate the Transact-SQL statements required to reconcile changes made to a <xref:System.Data.DataSet> with the associated instance of SQL Server. However, you can create a <xref:Microsoft.Data.SqlClient.SqlCommandBuilder> object to automatically generate Transact-SQL statements for single-table updates if you set the <xref:Microsoft.Data.SqlClient.SqlDataAdapter.SelectCommand%2A> property of the <xref:Microsoft.Data.SqlClient.SqlDataAdapter>. Then, any additional Transact-SQL statements that you do not set are generated by the <xref:Microsoft.Data.SqlClient.SqlCommandBuilder>.
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlCommandBuilder> registers itself as a listener for <xref:Microsoft.Data.SqlClient.SqlDataAdapter.RowUpdating> events whenever you set the <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.DataAdapter%2A> property. You can only associate one <xref:Microsoft.Data.SqlClient.SqlDataAdapter> or <xref:Microsoft.Data.SqlClient.SqlCommandBuilder> object with each other at one time.
|
||
|
|
||
|
To generate INSERT, UPDATE, or DELETE statements, the <xref:Microsoft.Data.SqlClient.SqlCommandBuilder> uses the <xref:Microsoft.Data.SqlClient.SqlDataAdapter.SelectCommand%2A> property to retrieve a required set of metadata automatically. If you change the <xref:Microsoft.Data.SqlClient.SqlDataAdapter.SelectCommand%2A> after the metadata has been retrieved, such as after the first update, you should call the <xref:System.Data.Common.DbCommandBuilder.RefreshSchema%2A> method to update the metadata.
|
||
|
|
||
|
The `SelectCommand` must also return at least one primary key or unique column. If none are present, an **InvalidOperation** exception is generated, and the commands are not generated.
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlCommandBuilder> also uses the <xref:Microsoft.Data.SqlClient.SqlCommand.Connection%2A>, <xref:Microsoft.Data.SqlClient.SqlCommand.CommandTimeout%2A>, and <xref:Microsoft.Data.SqlClient.SqlCommand.Transaction%2A> properties referenced by the <xref:Microsoft.Data.SqlClient.SqlDataAdapter.SelectCommand%2A>. The user should call <xref:System.Data.Common.DbCommandBuilder.RefreshSchema%2A> if one or more of these properties are modified, or if the <xref:Microsoft.Data.SqlClient.SqlDataAdapter.SelectCommand%2A> itself is replaced. Otherwise the <xref:Microsoft.Data.SqlClient.SqlDataAdapter.InsertCommand%2A>, <xref:Microsoft.Data.SqlClient.SqlDataAdapter.UpdateCommand%2A>, and <xref:Microsoft.Data.SqlClient.SqlDataAdapter.DeleteCommand%2A> properties retain their previous values.
|
||
|
|
||
|
If you call <xref:System.ComponentModel.Component.Dispose%2A>, the <xref:Microsoft.Data.SqlClient.SqlCommandBuilder> is disassociated from the <xref:Microsoft.Data.SqlClient.SqlDataAdapter>, and the generated commands are no longer used.
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example uses the <xref:Microsoft.Data.SqlClient.SqlCommand>, along <xref:Microsoft.Data.SqlClient.SqlDataAdapter> and <xref:Microsoft.Data.SqlClient.SqlConnection>, to select rows from a data source. The example is passed a connection string, a query string that is a Transact-SQL SELECT statement, and a string that is the name of the database table. The example then creates a <xref:Microsoft.Data.SqlClient.SqlCommandBuilder>.
|
||
|
|
||
|
[!code-csharp[SqlCommandBuilder#1](~/../sqlclient/doc/samples/SqlCommandBuilder.cs#1)]
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommandBuilder.#ctor">
|
||
|
<summary>
|
||
|
Initializes a new instance of the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlCommandBuilder" />
|
||
|
class.
|
||
|
</summary><remarks>
|
||
|
To be added.
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommandBuilder.#ctor(Microsoft.Data.SqlClient.SqlDataAdapter)">
|
||
|
<param name="adapter">
|
||
|
The name of the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlDataAdapter" />
|
||
|
.
|
||
|
</param><summary>
|
||
|
Initializes a new instance of the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlCommandBuilder" />
|
||
|
class with the associated
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlDataAdapter" />
|
||
|
object.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlCommandBuilder> registers itself as a listener for <xref:Microsoft.Data.SqlClient.SqlDataAdapter.RowUpdating> events that are generated by the <xref:Microsoft.Data.SqlClient.SqlDataAdapter> specified in this property.
|
||
|
|
||
|
When you create a new instance of <xref:Microsoft.Data.SqlClient.SqlCommandBuilder>, any existing <xref:Microsoft.Data.SqlClient.SqlCommandBuilder> associated with this <xref:Microsoft.Data.SqlClient.SqlDataAdapter> is released.
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlCommandBuilder.CatalogLocation">
|
||
|
<summary>
|
||
|
Sets or gets the
|
||
|
<see cref="T:System.Data.Common.CatalogLocation" />
|
||
|
for an instance of the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlCommandBuilder" />
|
||
|
class.
|
||
|
</summary><value>
|
||
|
A
|
||
|
<see cref="T:System.Data.Common.CatalogLocation" />
|
||
|
object.
|
||
|
</value><remarks>
|
||
|
To be added.
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlCommandBuilder.CatalogSeparator">
|
||
|
<summary>
|
||
|
Sets or gets a string used as the catalog separator for an instance of the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlCommandBuilder" />
|
||
|
class.
|
||
|
</summary><value>
|
||
|
A string that indicates the catalog separator for use with an instance of the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlCommandBuilder" />
|
||
|
class.
|
||
|
</value><remarks>
|
||
|
To be added.
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlCommandBuilder.DataAdapter">
|
||
|
<summary>Gets or sets a <see cref="T:Microsoft.Data.SqlClient.SqlDataAdapter" /> object for which Transact-SQL statements are automatically generated.</summary><value>A <see cref="T:Microsoft.Data.SqlClient.SqlDataAdapter" /> object.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlCommandBuilder> registers itself as a listener for <xref:Microsoft.Data.SqlClient.SqlDataAdapter.RowUpdating> events that are generated by the <xref:Microsoft.Data.SqlClient.SqlDataAdapter> specified in this property.
|
||
|
|
||
|
When you create a new instance of <xref:Microsoft.Data.SqlClient.SqlCommandBuilder>, any existing <xref:Microsoft.Data.SqlClient.SqlCommandBuilder> associated with this <xref:Microsoft.Data.SqlClient.SqlDataAdapter> is released.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommandBuilder.DeriveParameters(Microsoft.Data.SqlClient.SqlCommand)">
|
||
|
<param name="command">The <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> referencing the stored procedure from which the parameter information is to be derived. The derived parameters are added to the <see cref="P:Microsoft.Data.SqlClient.SqlCommand.Parameters" /> collection of the <see cref="T:Microsoft.Data.SqlClient.SqlCommand" />.</param><summary>Retrieves parameter information from the stored procedure specified in the <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> and populates the <see cref="P:Microsoft.Data.SqlClient.SqlCommand.Parameters" /> collection of the specified <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> object.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
`DeriveParameters` overwrites any existing parameter information for the `SqlDbCommand`.
|
||
|
|
||
|
`DeriveParameters` requires an additional call to the database to obtain the information. If the parameter information is known in advance, it is more efficient to populate the parameters collection by setting the information explicitly.
|
||
|
|
||
|
You can only use `DeriveParameters` with stored procedures. You cannot use `DeriveParameters` with extended stored procedures. You cannot use `DeriveParameters` to populate the <xref:Microsoft.Data.SqlClient.SqlParameterCollection> with arbitrary Transact-SQL statements, such as a parameterized SELECT statement.
|
||
|
|
||
|
For more information, see [Configuring parameters](/sql/connect/ado-net/configure-parameters).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidOperationException">The command text is not a valid stored procedure name.</exception>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlCommandBuilder.QuotePrefix">
|
||
|
<summary>Gets or sets the starting character or characters to use when specifying SQL Server database objects, such as tables or columns, whose names contain characters such as spaces or reserved tokens.</summary><value>The starting character or characters to use. The default is an empty string.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
|
||
|
> [!NOTE]
|
||
|
> Although you cannot change the <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.QuotePrefix%2A> or <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.QuoteSuffix%2A> properties after an insert, update, or delete command has been generated, you can change their settings after calling the `Update` method of a DataAdapter.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidOperationException">This property cannot be changed after an INSERT, UPDATE, or DELETE command has been generated.</exception>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlCommandBuilder.QuoteSuffix">
|
||
|
<summary>Gets or sets the ending character or characters to use when specifying SQL Server database objects, such as tables or columns, whose names contain characters such as spaces or reserved tokens.</summary><value>The ending character or characters to use. The default is an empty string.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
|
||
|
> [!NOTE]
|
||
|
> Although you cannot change the <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.QuotePrefix%2A> or <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.QuoteSuffix%2A> properties after an insert, update, or delete operation has been generated, you can change their settings after calling the `Update` method of a DataAdapter.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidOperationException">This property cannot be changed after an insert, update, or delete command has been generated.</exception>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlCommandBuilder.SchemaSeparator">
|
||
|
<summary>Gets or sets the character to be used for the separator between the schema identifier and any other identifiers.</summary><value>The character to be used as the schema separator.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Generally, database servers indicate the schema for a identifier by separating the schema name from the identifier with some character. For example, SQL Server uses a period, creating complete identifiers such as Person.CustomerName, where "Person" is the schema name and "CustomerName" is the identifier. Setting this property lets developers modify this behavior.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommandBuilder.ApplyParameterInfo(System.Data.Common.DbParameter,System.Data.DataRow,System.Data.StatementType,System.Boolean)">
|
||
|
<param name="parameter">
|
||
|
To be added.
|
||
|
</param><param name="datarow">
|
||
|
To be added.
|
||
|
</param><param name="statementType">
|
||
|
To be added.
|
||
|
</param><param name="whereClause">
|
||
|
To be added.
|
||
|
</param><summary>
|
||
|
To be added.
|
||
|
</summary><remarks>
|
||
|
To be added.
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommandBuilder.GetDeleteCommand">
|
||
|
<summary>Gets the automatically generated <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> object required to perform deletions on the database.</summary><returns>The automatically generated <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> object required to perform deletions.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
An application can use the <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.GetDeleteCommand%2A> method for informational or troubleshooting purposes because it returns the <xref:Microsoft.Data.SqlClient.SqlCommand> object to be executed.
|
||
|
|
||
|
You can also use <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.GetDeleteCommand%2A> as the basis of a modified command. For example, you might call <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.GetDeleteCommand%2A> and modify the <xref:Microsoft.Data.SqlClient.SqlCommand.CommandTimeout%2A> value, and then explicitly set that on the <xref:Microsoft.Data.SqlClient.SqlDataAdapter>.
|
||
|
|
||
|
After the SQL statement is first generated, the application must explicitly call <xref:System.Data.Common.DbCommandBuilder.RefreshSchema%2A> if it changes the statement in any way. Otherwise, the <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.GetDeleteCommand%2A> will still be using information from the previous statement, which might not be correct. The SQL statements are first generated when the application calls either <xref:System.Data.Common.DbDataAdapter.Update%2A> or <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.GetDeleteCommand%2A>.
|
||
|
|
||
|
For more information, see [Generating Commands with CommandBuilders](/sql/connect/ado-net/generate-commands-with-commandbuilders).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommandBuilder.GetDeleteCommand(System.Boolean)">
|
||
|
<param name="useColumnsForParameterNames">If <see langword="true" />, generate parameter names matching column names if possible. If <see langword="false" />, generate <c>@p1</c>, <c>@p2</c>, and so on.</param><summary>Gets the automatically generated <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> object that is required to perform deletions on the database.</summary><returns>The automatically generated <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> object that is required to perform deletions.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
An application can use the <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.GetDeleteCommand%2A> method for informational or troubleshooting purposes because it returns the <xref:Microsoft.Data.SqlClient.SqlCommand> object to be executed.
|
||
|
|
||
|
You can also use <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.GetDeleteCommand%2A> as the basis of a modified command. For example, you might call <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.GetDeleteCommand%2A> and modify the <xref:Microsoft.Data.SqlClient.SqlCommand.CommandTimeout%2A> value, and then explicitly set that on the <xref:Microsoft.Data.SqlClient.SqlDataAdapter>.
|
||
|
|
||
|
After the SQL statement is first generated, the application must explicitly call <xref:System.Data.Common.DbCommandBuilder.RefreshSchema%2A> if it changes the statement in any way. Otherwise, the <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.GetDeleteCommand%2A> will still be using information from the previous statement, which might not be correct. The SQL statements are first generated when the application calls either <xref:System.Data.Common.DbDataAdapter.Update%2A> or <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.GetDeleteCommand%2A>.
|
||
|
|
||
|
The default behavior, when generating parameter names, is to use `@p1`, `@p2`, and so on for the various parameters. Passing `true` for the `useColumnsForParameterNames` parameter lets you force the <xref:System.Data.OleDb.OleDbCommandBuilder> to generate parameters based on the column names instead. This succeeds only if the following conditions are met:
|
||
|
|
||
|
- The <xref:System.Data.Common.DbMetaDataColumnNames.ParameterNameMaxLength> returned from the **GetSchema** method call and found in the <xref:System.Data.Common.DbMetaDataCollectionNames.DataSourceInformation> collection has been specified and its length is equal to or greater than the generated parameter name.
|
||
|
|
||
|
- The generated parameter name meets the criteria specified in the <xref:System.Data.Common.DbMetaDataColumnNames.ParameterNamePattern> returned from the **GetSchema** method call and found in the <xref:System.Data.Common.DbMetaDataCollectionNames.DataSourceInformation> collection regular expression.
|
||
|
|
||
|
- A <xref:System.Data.Common.DbMetaDataColumnNames.ParameterMarkerFormat> returned from the **GetSchema** method call and found in the <xref:System.Data.Common.DbMetaDataCollectionNames.DataSourceInformation> collection is specified.
|
||
|
|
||
|
For more information, see [Generating Commands with CommandBuilders](/sql/connect/ado-net/generate-commands-with-commandbuilders).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommandBuilder.GetInsertCommand">
|
||
|
<summary>Gets the automatically generated <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> object required to perform insertions on the database.</summary><returns>The automatically generated <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> object required to perform insertions.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
An application can use the <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.GetInsertCommand%2A> method for informational or troubleshooting purposes because it returns the <xref:Microsoft.Data.SqlClient.SqlCommand> object to be executed.
|
||
|
|
||
|
You can also use <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.GetInsertCommand%2A> as the basis of a modified command. For example, you might call <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.GetInsertCommand%2A> and modify the <xref:Microsoft.Data.SqlClient.SqlCommand.CommandTimeout%2A> value, and then explicitly set that on the <xref:Microsoft.Data.SqlClient.SqlDataAdapter>.
|
||
|
|
||
|
After the Transact-SQL statement is first generated, the application must explicitly call <xref:System.Data.Common.DbCommandBuilder.RefreshSchema%2A> if it changes the statement in any way. Otherwise, the <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.GetInsertCommand%2A> will still be using information from the previous statement, which might not be correct. The Transact-SQL statements are first generated when the application calls either <xref:System.Data.Common.DbDataAdapter.Update%2A> or <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.GetInsertCommand%2A>.
|
||
|
|
||
|
For more information, see [Generating Commands with CommandBuilders](/sql/connect/ado-net/generate-commands-with-commandbuilders).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommandBuilder.GetInsertCommand(System.Boolean)">
|
||
|
<param name="useColumnsForParameterNames">If <see langword="true" />, generate parameter names matching column names if possible. If <see langword="false" />, generate <c>@p1</c>, <c>@p2</c>, and so on.</param><summary>Gets the automatically generated <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> object that is required to perform insertions on the database.</summary><returns>The automatically generated <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> object that is required to perform insertions.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
An application can use the <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.GetInsertCommand%2A> method for informational or troubleshooting purposes because it returns the <xref:Microsoft.Data.SqlClient.SqlCommand> object to be executed.
|
||
|
|
||
|
You can also use <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.GetInsertCommand%2A> as the basis of a modified command. For example, you might call <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.GetInsertCommand%2A> and modify the <xref:Microsoft.Data.SqlClient.SqlCommand.CommandTimeout%2A> value, and then explicitly set that on the <xref:Microsoft.Data.SqlClient.SqlDataAdapter>.
|
||
|
|
||
|
After the Transact-SQL statement is first generated, the application must explicitly call <xref:System.Data.Common.DbCommandBuilder.RefreshSchema%2A> if it changes the statement in any way. Otherwise, the <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.GetInsertCommand%2A> will still be using information from the previous statement, which might not be correct. The Transact-SQL statements are first generated when the application calls either <xref:System.Data.Common.DbDataAdapter.Update%2A> or <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.GetInsertCommand%2A>.
|
||
|
|
||
|
The default behavior, when generating parameter names, is to use `@p1`, `@p2`, and so on for the various parameters. Passing `true` for the `useColumnsForParameterNames` parameter lets you force the <xref:System.Data.OleDb.OleDbCommandBuilder> to generate parameters based on the column names instead. This succeeds only if the following conditions are met:
|
||
|
|
||
|
- The <xref:System.Data.Common.DbMetaDataColumnNames.ParameterNameMaxLength> returned from the **GetSchema** method call and found in the <xref:System.Data.Common.DbMetaDataCollectionNames.DataSourceInformation> collection has been specified and its length is equal to or greater than the generated parameter name.
|
||
|
|
||
|
- The generated parameter name meets the criteria specified in the <xref:System.Data.Common.DbMetaDataColumnNames.ParameterNamePattern> returned from the **GetSchema** method call and found in the <xref:System.Data.Common.DbMetaDataCollectionNames.DataSourceInformation> collection regular expression.
|
||
|
|
||
|
- A <xref:System.Data.Common.DbMetaDataColumnNames.ParameterMarkerFormat> returned from the **GetSchema** method call and found in the <xref:System.Data.Common.DbMetaDataCollectionNames.DataSourceInformation> collection is specified.
|
||
|
|
||
|
For more information, see [Generating Commands with CommandBuilders](/sql/connect/ado-net/generate-commands-with-commandbuilders).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommandBuilder.GetParameterName(System.Int32)">
|
||
|
<param name="parameterOrdinal">To be added.</param><summary>To be added.</summary><returns>To be added.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommandBuilder.GetParameterName(System.String)">
|
||
|
<param name="parameterName">To be added.</param><summary>To be added.</summary><returns>To be added.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommandBuilder.GetParameterPlaceholder(System.Int32)">
|
||
|
<param name="parameterOrdinal">To be added.</param><summary>To be added.</summary><returns>To be added.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommandBuilder.GetSchemaTable(System.Data.Common.DbCommand)">
|
||
|
<param name="srcCommand">To be added.</param><summary>To be added.</summary><returns>To be added.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommandBuilder.GetUpdateCommand">
|
||
|
<summary>Gets the automatically generated <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> object required to perform updates on the database.</summary><returns>The automatically generated <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> object that is required to perform updates.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
An application can use the <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.GetUpdateCommand%2A> method for informational or troubleshooting purposes because it returns the <xref:Microsoft.Data.SqlClient.SqlCommand> object to be executed.
|
||
|
|
||
|
You can also use <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.GetUpdateCommand%2A> as the basis of a modified command. For example, you might call <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.GetUpdateCommand%2A> and modify the <xref:Microsoft.Data.SqlClient.SqlCommand.CommandTimeout%2A> value, and then explicitly set that on the <xref:Microsoft.Data.SqlClient.SqlDataAdapter>.
|
||
|
|
||
|
After the Transact-SQL statement is first generated, the application must explicitly call <xref:System.Data.Common.DbCommandBuilder.RefreshSchema%2A> if it changes the statement in any way. Otherwise, the <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.GetUpdateCommand%2A> will still be using information from the previous statement, which might not be correct. The Transact-SQL statements are first generated when the application calls either <xref:System.Data.Common.DbDataAdapter.Update%2A> or <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.GetUpdateCommand%2A>.
|
||
|
|
||
|
For more information, see [Generating Commands with CommandBuilders](/sql/connect/ado-net/generate-commands-with-commandbuilders).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommandBuilder.GetUpdateCommand(System.Boolean)">
|
||
|
<param name="useColumnsForParameterNames">If <see langword="true" />, generate parameter names matching column names if possible. If <see langword="false" />, generate <c>@p1</c>, <c>@p2</c>, and so on.</param><summary>Gets the automatically generated <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> object required to perform updates on the database.</summary><returns>The automatically generated <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> object required to perform updates.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
An application can use the <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.GetUpdateCommand%2A> method for informational or troubleshooting purposes because it returns the <xref:Microsoft.Data.SqlClient.SqlCommand> object to be executed.
|
||
|
|
||
|
You can also use <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.GetUpdateCommand%2A> as the basis of a modified command. For example, you might call <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.GetUpdateCommand%2A> and modify the <xref:Microsoft.Data.SqlClient.SqlCommand.CommandTimeout%2A> value, and then explicitly set that on the <xref:Microsoft.Data.SqlClient.SqlDataAdapter>.
|
||
|
|
||
|
After the Transact-SQL statement is first generated, the application must explicitly call <xref:System.Data.Common.DbCommandBuilder.RefreshSchema%2A> if it changes the statement in any way. Otherwise, the <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.GetUpdateCommand%2A> will still be using information from the previous statement, which might not be correct. The Transact-SQL statements are first generated when the application calls either <xref:System.Data.Common.DbDataAdapter.Update%2A> or <xref:Microsoft.Data.SqlClient.SqlCommandBuilder.GetUpdateCommand%2A>.
|
||
|
|
||
|
The default behavior, when generating parameter names, is to use `@p1`, `@p2`, and so on for the various parameters. Passing `true` for the `useColumnsForParameterNames` parameter lets you force the <xref:System.Data.OleDb.OleDbCommandBuilder> to generate parameters based on the column names instead. This succeeds only if the following conditions are met:
|
||
|
|
||
|
- The <xref:System.Data.Common.DbMetaDataColumnNames.ParameterNameMaxLength> returned from the **GetSchema** method call and found in the <xref:System.Data.Common.DbMetaDataCollectionNames.DataSourceInformation> collection has been specified and its length is equal to or greater than the generated parameter name.
|
||
|
|
||
|
- The generated parameter name meets the criteria specified in the <xref:System.Data.Common.DbMetaDataColumnNames.ParameterNamePattern> returned from the **GetSchema** method call and found in the <xref:System.Data.Common.DbMetaDataCollectionNames.DataSourceInformation> collection regular expression.
|
||
|
|
||
|
- A <xref:System.Data.Common.DbMetaDataColumnNames.ParameterMarkerFormat> returned from the **GetSchema** method call and found in the <xref:System.Data.Common.DbMetaDataCollectionNames.DataSourceInformation> collection is specified.
|
||
|
|
||
|
For more information, see [Generating Commands with CommandBuilders](/sql/connect/ado-net/generate-commands-with-commandbuilders).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommandBuilder.InitializeCommand(System.Data.Common.DbCommand)">
|
||
|
<param name="command">To be added.</param><summary>To be added.</summary><returns>To be added.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommandBuilder.QuoteIdentifier(System.String)">
|
||
|
<param name="unquotedIdentifier">To be added.</param><summary>To be added.</summary><returns>To be added.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommandBuilder.SetRowUpdatingHandler(System.Data.Common.DbDataAdapter)">
|
||
|
<param name="adapter">To be added.</param><summary>To be added.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCommandBuilder.UnquoteIdentifier(System.String)">
|
||
|
<param name="quotedIdentifier">The identifier that will have its embedded quotes removed.</param><summary>Given a quoted identifier, returns the correct unquoted form of that identifier. This includes correctly unescaping any embedded quotes in the identifier.</summary><returns>The unquoted identifier, with embedded quotes properly unescaped.</returns><remarks>To be added.</remarks><related type="Article" href="/sql/connect/ado-net/retrieving-modifying-data">Connecting and Retrieving Data in ADO.NET</related><related type="Article" href="/sql/connect/ado-net/sql/">Using the .NET Framework Data Provider for SQL Server</related><related type="Article" href="/sql/connect/ado-net/overview-sqlclient-driver">Overview of the SqlClient driver</related>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlConnection">
|
||
|
<summary>Represents a connection to a SQL Server database. This class cannot be inherited.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
A <xref:Microsoft.Data.SqlClient.SqlConnection> object represents a unique session to a SQL Server data source. With a client/server database system, it is equivalent to a network connection to the server. <xref:Microsoft.Data.SqlClient.SqlConnection> is used together with <xref:Microsoft.Data.SqlClient.SqlDataAdapter> and <xref:Microsoft.Data.SqlClient.SqlCommand> to increase performance when connecting to a Microsoft SQL Server database. For all third-party SQL Server products and other OLE DB-supported data sources, use <xref:System.Data.OleDb.OleDbConnection>.
|
||
|
|
||
|
When you create an instance of <xref:Microsoft.Data.SqlClient.SqlConnection>, all properties are set to their initial values. For a list of these values, see the <xref:Microsoft.Data.SqlClient.SqlConnection> constructor.
|
||
|
|
||
|
See <xref:Microsoft.Data.SqlClient.SqlConnection.ConnectionString%2A> for a list of the keywords in a connection string.
|
||
|
|
||
|
If the <xref:Microsoft.Data.SqlClient.SqlConnection> goes out of scope, it won't be closed. Therefore, you must explicitly close the connection by calling `Close` or `Dispose`. `Close` and `Dispose` are functionally equivalent. If the connection pooling value `Pooling` is set to `true` or `yes`, the underlying connection is returned back to the connection pool. On the other hand, if `Pooling` is set to `false` or `no`, the underlying connection to the server is actually closed.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> Login and logout events will not be raised on the server when a connection is fetched from or returned to the connection pool, because the connection is not actually closed when it is returned to the connection pool. For more information, see [SQL Server Connection Pooling (ADO.NET)](/sql/connect/ado-net/sql-server-connection-pooling).
|
||
|
|
||
|
To ensure that connections are always closed, open the connection inside of a `using` block, as shown in the following code fragment. Doing so ensures that the connection is automatically closed when the code exits the block.
|
||
|
|
||
|
```vb
|
||
|
Using connection As New SqlConnection(connectionString)
|
||
|
connection.Open()
|
||
|
' Do work here; connection closed on following line.
|
||
|
End Using
|
||
|
|
||
|
```
|
||
|
|
||
|
```csharp
|
||
|
using (SqlConnection connection = new SqlConnection(connectionString))
|
||
|
{
|
||
|
connection.Open();
|
||
|
// Do work here; connection closed on following line.
|
||
|
}
|
||
|
```
|
||
|
|
||
|
> [!NOTE]
|
||
|
> To deploy high-performance applications, you must use connection pooling. When you use the .NET Framework Data Provider for SQL Server, you do not have to enable connection pooling because the provider manages this automatically, although you can modify some settings. For more information, see [SQL Server Connection Pooling (ADO.NET)](/sql/connect/ado-net/sql-server-connection-pooling).
|
||
|
|
||
|
If a <xref:Microsoft.Data.SqlClient.SqlException> is generated by the method executing a <xref:Microsoft.Data.SqlClient.SqlCommand>, the <xref:Microsoft.Data.SqlClient.SqlConnection> remains open when the severity level is 19 or less. When the severity level is 20 or greater, the server ordinarily closes the <xref:Microsoft.Data.SqlClient.SqlConnection>. However, the user can reopen the connection and continue.
|
||
|
|
||
|
An application that creates an instance of the <xref:Microsoft.Data.SqlClient.SqlConnection> object can require all direct and indirect callers to have sufficient permission to the code by setting declarative or imperative security demands. <xref:Microsoft.Data.SqlClient.SqlConnection> makes security demands using the <xref:Microsoft.Data.SqlClient.SqlClientPermission> object. Users can verify that their code has sufficient permissions by using the <xref:Microsoft.Data.SqlClient.SqlClientPermissionAttribute> object. Users and administrators can also use the [Caspol.exe (Code Access Security Policy Tool)](/dotnet/framework/tools/caspol-exe-code-access-security-policy-tool) to modify security policy at the machine, user, and enterprise levels. For more information, see [Security in .NET](/dotnet/standard/security/). For an example demonstrating how to use security demands, see [Code Access Security and ADO.NET](/dotnet/framework/data/adonet/code-access-security).
|
||
|
|
||
|
For more information about handling warning and informational messages from the server, see [Connection Events](/sql/connect/ado-net/connection-events). For more information about SQL Server engine errors and error messages, see [Database Engine Events and Errors](/sql/relational-databases/errors-events/database-engine-events-and-errors).
|
||
|
|
||
|
> [!CAUTION]
|
||
|
> You can force TCP instead of shared memory. You can do that by prefixing tcp: to the server name in the connection string or you can use localhost.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlCommand> and a <xref:Microsoft.Data.SqlClient.SqlConnection>. The <xref:Microsoft.Data.SqlClient.SqlConnection> is opened and set as the <xref:Microsoft.Data.SqlClient.SqlCommand.Connection%2A> for the <xref:Microsoft.Data.SqlClient.SqlCommand>. The example then calls <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteNonQuery%2A>. To accomplish this, the <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteNonQuery%2A> is passed a connection string and a query string that is a Transact-SQL INSERT statement. The connection is closed automatically when the code exits the using block.
|
||
|
|
||
|
[!code-csharp[SqlCommand_ExecuteNonQuery Example#1](~/../sqlclient/doc/samples/SqlCommand_ExecuteNonQuery.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
<summary>Represents a connection to a SQL Server database. This class cannot be inherited.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
A <xref:Microsoft.Data.SqlClient.SqlConnection> object represents a unique session to a SQL Server data source. With a client/server database system, it is equivalent to a network connection to the server. <xref:Microsoft.Data.SqlClient.SqlConnection> is used together with <xref:Microsoft.Data.SqlClient.SqlDataAdapter> and <xref:Microsoft.Data.SqlClient.SqlCommand> to increase performance when connecting to a Microsoft SQL Server database. For all third-party SQL Server products and other OLE DB-supported data sources, use <xref:System.Data.OleDb.OleDbConnection>.
|
||
|
|
||
|
When you create an instance of <xref:Microsoft.Data.SqlClient.SqlConnection>, all properties are set to their initial values. For a list of these values, see the <xref:Microsoft.Data.SqlClient.SqlConnection> constructor.
|
||
|
|
||
|
See <xref:Microsoft.Data.SqlClient.SqlConnection.ConnectionString%2A> for a list of the keywords in a connection string.
|
||
|
|
||
|
If the <xref:Microsoft.Data.SqlClient.SqlConnection> goes out of scope, it won't be closed. Therefore, you must explicitly close the connection by calling `Close` or `Dispose`. `Close` and `Dispose` are functionally equivalent. If the connection pooling value `Pooling` is set to `true` or `yes`, the underlying connection is returned back to the connection pool. On the other hand, if `Pooling` is set to `false` or `no`, the underlying connection to the server is actually closed.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> Login and logout events will not be raised on the server when a connection is fetched from or returned to the connection pool, because the connection is not actually closed when it is returned to the connection pool. For more information, see [SQL Server Connection Pooling (ADO.NET)](/sql/connect/ado-net/sql-server-connection-pooling).
|
||
|
|
||
|
To ensure that connections are always closed, open the connection inside of a `using` block, as shown in the following code fragment. Doing so ensures that the connection is automatically closed when the code exits the block.
|
||
|
|
||
|
```vb
|
||
|
Using connection As New SqlConnection(connectionString)
|
||
|
connection.Open()
|
||
|
' Do work here; connection closed on following line.
|
||
|
End Using
|
||
|
|
||
|
```
|
||
|
|
||
|
```csharp
|
||
|
using (SqlConnection connection = new SqlConnection(connectionString))
|
||
|
{
|
||
|
connection.Open();
|
||
|
// Do work here; connection closed on following line.
|
||
|
}
|
||
|
```
|
||
|
|
||
|
> [!NOTE]
|
||
|
> To deploy high-performance applications, you must use connection pooling. When you use the .NET Framework Data Provider for SQL Server, you do not have to enable connection pooling because the provider manages this automatically, although you can modify some settings. For more information, see [SQL Server Connection Pooling (ADO.NET)](/sql/connect/ado-net/sql-server-connection-pooling).
|
||
|
|
||
|
If a <xref:Microsoft.Data.SqlClient.SqlException> is generated by the method executing a <xref:Microsoft.Data.SqlClient.SqlCommand>, the <xref:Microsoft.Data.SqlClient.SqlConnection> remains open when the severity level is 19 or less. When the severity level is 20 or greater, the server ordinarily closes the <xref:Microsoft.Data.SqlClient.SqlConnection>. However, the user can reopen the connection and continue.
|
||
|
|
||
|
An application that creates an instance of the <xref:Microsoft.Data.SqlClient.SqlConnection> object can require all direct and indirect callers to have sufficient permission to the code by setting declarative or imperative security demands. <xref:Microsoft.Data.SqlClient.SqlConnection> makes security demands using the <xref:Microsoft.Data.SqlClient.SqlClientPermission> object. Users can verify that their code has sufficient permissions by using the <xref:Microsoft.Data.SqlClient.SqlClientPermissionAttribute> object. Users and administrators can also use the [Caspol.exe (Code Access Security Policy Tool)](/dotnet/framework/tools/caspol-exe-code-access-security-policy-tool) to modify security policy at the machine, user, and enterprise levels. For more information, see [Security in .NET](/dotnet/standard/security/). For an example demonstrating how to use security demands, see [Code Access Security and ADO.NET](/dotnet/framework/data/adonet/code-access-security).
|
||
|
|
||
|
For more information about handling warning and informational messages from the server, see [Connection Events](/sql/connect/ado-net/connection-events). For more information about SQL Server engine errors and error messages, see [Database Engine Events and Errors](/sql/relational-databases/errors-events/database-engine-events-and-errors).
|
||
|
|
||
|
> [!CAUTION]
|
||
|
> You can force TCP instead of shared memory. You can do that by prefixing tcp: to the server name in the connection string or you can use localhost.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlCommand> and a <xref:Microsoft.Data.SqlClient.SqlConnection>. The <xref:Microsoft.Data.SqlClient.SqlConnection> is opened and set as the <xref:Microsoft.Data.SqlClient.SqlCommand.Connection%2A> for the <xref:Microsoft.Data.SqlClient.SqlCommand>. The example then calls <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteNonQuery%2A>. To accomplish this, the <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteNonQuery%2A> is passed a connection string and a query string that is a Transact-SQL INSERT statement. The connection is closed automatically when the code exits the using block.
|
||
|
|
||
|
[!code-csharp[SqlCommand_ExecuteNonQuery Example#1](~/../sqlclient/doc/samples/SqlCommand_ExecuteNonQuery.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnection.#ctor">
|
||
|
<summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.SqlConnection" /> class.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
When a new instance of <xref:Microsoft.Data.SqlClient.SqlConnection> is created, the read/write properties are set to the following initial values unless they are specifically set using their associated keywords in the <xref:Microsoft.Data.SqlClient.SqlConnection.ConnectionString%2A> property.
|
||
|
|
||
|
|Properties|Initial value|
|
||
|
|----------------|-------------------|
|
||
|
|<xref:Microsoft.Data.SqlClient.SqlConnection.ConnectionString%2A>|empty string ("")|
|
||
|
|<xref:Microsoft.Data.SqlClient.SqlConnection.ConnectionTimeout%2A>|15|
|
||
|
|<xref:Microsoft.Data.SqlClient.SqlConnection.Database%2A>|empty string ("")|
|
||
|
|<xref:Microsoft.Data.SqlClient.SqlConnection.DataSource%2A>|empty string ("")|
|
||
|
|
||
|
You can change the value for these properties only by using the <xref:Microsoft.Data.SqlClient.SqlConnection.ConnectionString%2A> property. The <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder> class provides functionality for creating and managing the contents of connection strings.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates and opens a <xref:Microsoft.Data.SqlClient.SqlConnection>.
|
||
|
|
||
|
[!code-csharp[SqlConnection_SqlConnection Example#1](~/../sqlclient/doc/samples/SqlConnection_SqlConnection.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnection.#ctor(System.String)">
|
||
|
<param name="connectionString">The connection used to open the SQL Server database.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.SqlConnection" /> class when given a string that contains the connection string.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
When a new instance of <xref:Microsoft.Data.SqlClient.SqlConnection> is created, the read/write properties are set to the following initial values unless they are specifically set using their associated keywords in the <xref:Microsoft.Data.SqlClient.SqlConnection.ConnectionString%2A> property.
|
||
|
|
||
|
|Properties|Initial value|
|
||
|
|----------------|-------------------|
|
||
|
|<xref:Microsoft.Data.SqlClient.SqlConnection.ConnectionString%2A>|`connectionString`|
|
||
|
|<xref:Microsoft.Data.SqlClient.SqlConnection.ConnectionTimeout%2A>|15|
|
||
|
|<xref:Microsoft.Data.SqlClient.SqlConnection.Database%2A>|empty string ("")|
|
||
|
|<xref:Microsoft.Data.SqlClient.SqlConnection.DataSource%2A>|empty string ("")|
|
||
|
|
||
|
You can change the value for these properties only by using the <xref:Microsoft.Data.SqlClient.SqlConnection.ConnectionString%2A> property. The <xref:Microsoft.Data.SqlClient.SqlConnection> class provides functionality for creating and managing the contents of connection strings.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates and opens a <xref:Microsoft.Data.SqlClient.SqlConnection>.
|
||
|
|
||
|
[!code-csharp[SqlConnection_SqlConnection1 Example#1](~/../sqlclient/doc/samples/SqlConnection_SqlConnection1.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentException">The supplied connection string argument failed <see cref="T:Microsoft.Data.SqlClient.SqlConnection.ConnectionString" /> validation.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnection.#ctor(System.String,Microsoft.Data.SqlClient.SqlCredential)">
|
||
|
<param name="connectionString">A connection string that does not use any of the following connection string keywords: <see langword="Integrated Security = true" />, <see langword="UserId" />, or <see langword="Password" />; or that does not use <see langword="ContextConnection = true" />.</param><param name="credential">A <see cref="T:Microsoft.Data.SqlClient.SqlCredential" /> object. If <paramref name="credential" /> is null, <see cref="M:Microsoft.Data.SqlClient.SqlConnection.#ctor(System.String,Microsoft.Data.SqlClient.SqlCredential)" /> is functionally equivalent to <see cref="M:Microsoft.Data.SqlClient.SqlConnection.#ctor(System.String)" />.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.SqlConnection" /> class given a connection string, that does not use <see langword="Integrated Security = true" /> and a <see cref="T:Microsoft.Data.SqlClient.SqlCredential" /> object that contains the user ID and password.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">The supplied arguments failed validation, including <see cref="T:Microsoft.Data.SqlClient.SqlConnection.ConnectionString" /> validation.</exception>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnection.ColumnEncryptionKeyCacheTtl">
|
||
|
<summary>Gets or sets the time-to-live for column encryption key entries in the column encryption key cache for the <see href="https://docs.microsoft.com/sql/relational-databases/security/encryption/always-encrypted-database-engine">Always Encrypted</see> feature. The default value is 2 hours. 0 means no caching at all.</summary><value>The time interval.</value><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnection.ColumnEncryptionQueryMetadataCacheEnabled">
|
||
|
<summary>Gets or sets a value that indicates whether query metadata caching is enabled (true) or not (false) for parameterized queries running against <see href="https://docs.microsoft.com/sql/relational-databases/security/encryption/always-encrypted-database-engine">Always Encrypted</see> enabled databases. The default value is true.</summary><value>Returns true if query metadata caching is enabled; otherwise false. true is the default.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
For parameterized queries, SqlClient makes a roundtrip to SQL Server for parameter metadata, to see which parameter it needs to encrypt and how (which keys and algorithms should be used). If the application calls the same query multiple times, an extra roundtrip is made to the server each time, which degrades application performance.
|
||
|
|
||
|
With **ColumnEncryptionQueryMetadataCacheEnabled** set to true, if the same query is called multiple times, the roundtrip to the server will be made only once. The cache has a non-configurable Max size parameter that is set to 2000 queries.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnection.ColumnEncryptionTrustedMasterKeyPaths">
|
||
|
<summary>Allows you to set a list of trusted key paths for a database server. If while processing an application query the driver receives a key path that is not on the list, the query will fail. This property provides additional protection against security attacks that involve a compromised SQL Server providing fake key paths, which may lead to leaking key store credentials.</summary><value>The list of trusted master key paths for the column encryption.</value><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnection.RegisterColumnEncryptionKeyStoreProviders(System.Collections.Generic.IDictionary{System.String,Microsoft.Data.SqlClient.SqlColumnEncryptionKeyStoreProvider})">
|
||
|
<param name="customProviders">Dictionary of custom column encryption key store providers</param><summary>
|
||
|
Registers the column encryption key store providers. This function should only be called once in an app. This does shallow copying of the dictionary so that the app cannot alter the custom provider list once it has been set.
|
||
|
|
||
|
The built-in column master key store providers that are available for the Windows Certificate Store, CNG Store and CSP are pre-registered.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
## Examples
|
||
|
```csharp
|
||
|
Dictionary<string, SqlColumnEncryptionKeyStoreProvider> customKeyStoreProviders = new Dictionary<string, SqlColumnEncryptionKeyStoreProvider>();
|
||
|
MySqlClientHSMProvider myProvider = new MySqlClientHSMProvider();
|
||
|
customKeyStoreProviders.Add(@"HSM Provider", myProvider);
|
||
|
SqlConnection.RegisterColumnEncryptionKeyStoreProviders(customKeyStoreProviders);
|
||
|
```
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">
|
||
|
A null dictionary was provided.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A string key in the dictionary was null or empty.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A <see cref="T:Microsoft.Data.SqlClient.SqlColumnEncryptionKeyStoreProvider" /> value in the dictionary was null.
|
||
|
</exception><exception cref="T:System.ArgumentException">
|
||
|
A string key in the dictionary started with "MSSQL_". This prefix is reserved for system providers.
|
||
|
</exception><exception cref="T:System.InvalidOperationException">
|
||
|
This function was called more than once.
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnection.RegisterColumnEncryptionKeyStoreProvidersOnConnection(System.Collections.Generic.IDictionary{System.String,Microsoft.Data.SqlClient.SqlColumnEncryptionKeyStoreProvider})">
|
||
|
<param name="customProviders">Dictionary of custom column encryption key providers</param><summary>Registers the encryption key store providers on the <see cref="T:Microsoft.Data.SqlClient.SqlConnection" /> instance. If this function has been called, any providers registered using the static <see cref="M:Microsoft.Data.SqlClient.SqlConnection.RegisterColumnEncryptionKeyStoreProviders(System.Collections.Generic.IDictionary{System.String,Microsoft.Data.SqlClient.SqlColumnEncryptionKeyStoreProvider})" /> methods will be ignored. This function can be called more than once. This does shallow copying of the dictionary so that the app cannot alter the custom provider list once it has been set.</summary><exception cref="T:System.ArgumentNullException">
|
||
|
A null dictionary was provided.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A string key in the dictionary was null or empty.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
A <see cref="T:Microsoft.Data.SqlClient.SqlColumnEncryptionKeyStoreProvider" /> value in the dictionary was null.
|
||
|
</exception><exception cref="T:System.ArgumentException">
|
||
|
A string key in the dictionary started with "MSSQL_". This prefix is reserved for system providers.
|
||
|
</exception><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
## Remarks
|
||
|
Custom master key store providers can be registered with the driver at three different layers. The precedence of the three registrations is as follows:
|
||
|
|
||
|
- The per-command registration will be checked if it is not empty.
|
||
|
- If the per-command registration is empty, the per-connection registration will be checked if it is not empty.
|
||
|
- If the per-connection registration is empty, the global registration will be checked.
|
||
|
|
||
|
Once any key store provider is found at a registration level, the driver will **NOT** fall back to the other registrations to search for a provider. If providers are registered but the proper provider is not found at a level, an exception will be thrown containing only the registered providers in the registration that was checked.
|
||
|
|
||
|
The built-in column master key store providers that are available for the Windows Certificate Store, CNG Store and CSP are pre-registered.
|
||
|
|
||
|
This does shallow copying of the dictionary so that the app cannot alter the custom provider list once it has been set.
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnection.AccessToken">
|
||
|
<summary>Gets or sets the access token for the connection.</summary><value>The access token for the connection.</value><remarks>
|
||
|
<format type="text/markdown">
|
||
|
<![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The AccessToken is a part of the connection pool key. Care should be taken when using this property to manage your own access token. The application is responsible for knowing when the token expires and connections from the pool should no longer be used.
|
||
|
|
||
|
If you set a minimum pool size > 0 along with AccessToken, you must call <xref:Microsoft.Data.SqlClient.SqlConnection.ClearPool%2A> after the access token expires to ensure the connection pool doesn't maintain those connections indefinitely.
|
||
|
|
||
|
]]>
|
||
|
</format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnection.ClientConnectionId">
|
||
|
<summary>The connection ID of the most recent connection attempt, regardless of whether the attempt succeeded or failed.</summary><value>The connection ID of the most recent connection attempt.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
<xref:Microsoft.Data.SqlClient.SqlConnection.ClientConnectionId%2A> works regardless of which version of the server you connect to, but extended events logs and entry on connectivity ring buffer errors will not be present in SQL Server 2008 R2 and earlier.
|
||
|
|
||
|
You can locate the connection ID in the extended events log to see if the failure was on the server if the extended event for logging connection ID is enabled. You can also locate the connection ID in the connection ring buffer ([Connectivity troubleshooting in SQL Server 2008 with the Connectivity Ring Buffer](https://go.microsoft.com/fwlink/?LinkId=207752)) for certain connection errors. If the connection ID is not in the connection ring buffer, you can assume a network error.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnection.AccessTokenCallback">
|
||
|
<summary>Gets or sets the access token callback for the connection.</summary><value>
|
||
|
The Func that takes a <see cref="T:Microsoft.Data.SqlClient.SqlAuthenticationParameters" /> and <see cref="T:System.Threading.CancellationToken" /> and returns a <see cref="T:Microsoft.Data.SqlClient.SqlAuthenticationToken" />.</value><remarks>
|
||
|
<format type="text/markdown">
|
||
|
<![CDATA[
|
||
|
|
||
|
## Examples
|
||
|
The following example demonstrates how to define and set an <xref:Microsoft.Data.SqlClient.SqlConnection.AccessTokenCallback%2A>.
|
||
|
|
||
|
[!code-csharp[SqlConnection_AccessTokenCallback Example#1](~/../sqlclient/doc/samples/SqlConnection_AccessTokenCallback.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidOperationException">The AccessTokenCallback is combined with other conflicting authentication configurations.</exception>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnection.SQLDNSCachingSupportedState">
|
||
|
|
||
|
for internal test only
|
||
|
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnection.SQLDNSCachingSupportedStateBeforeRedirect">
|
||
|
|
||
|
for internal test only
|
||
|
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnection.CommandTimeout">
|
||
|
<summary>
|
||
|
Gets the default wait time (in seconds) before terminating the attempt to execute a command and generating an error. The default is 30 seconds.
|
||
|
</summary><value>
|
||
|
The time in seconds to wait for the command to execute. The default is 30 seconds.
|
||
|
</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
|
||
|
You can set the default wait time by using the `Command Timeout` keyword in the connection string. A value of 0 indicates no limit (an attempt to execute a command will wait indefinitely).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnection.ConnectionString">
|
||
|
<summary>Gets or sets the string used to open a SQL Server database.</summary><value>The connection string that includes the source database name, and other parameters needed to establish the initial connection. The default value is an empty string.</value><remarks>
|
||
|
<format type="text/markdown">
|
||
|
<![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlConnection.ConnectionString%2A> is similar to an OLE DB connection string, but is not identical. Unlike OLE DB or ADO, the connection string that is returned is the same as the user-set <xref:Microsoft.Data.SqlClient.SqlConnection.ConnectionString%2A>, minus security information if the Persist Security Info value is set to `false` (default). The .NET Framework Data Provider for SQL Server does not persist or return the password in a connection string unless you set Persist Security Info to `true`.
|
||
|
You can use the <xref:Microsoft.Data.SqlClient.SqlConnection.ConnectionString%2A> property to connect to a database. The following example illustrates a typical connection string.
|
||
|
|
||
|
```
|
||
|
"Persist Security Info=False;Integrated Security=true;Initial Catalog=Northwind;server=(local)"
|
||
|
```
|
||
|
|
||
|
Use the new <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder> to construct valid connection strings at run time. For more information, see [Connection String Builders](/sql/connect/ado-net/connection-string-builders).
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlConnection.ConnectionString%2A> property can be set only when the connection is closed. Many of the connection string values have corresponding read-only properties. When the connection string is set, these properties are updated, except when an error is detected. In this case, none of the properties are updated. <xref:Microsoft.Data.SqlClient.SqlConnection> properties return only those settings that are contained in the <xref:Microsoft.Data.SqlClient.SqlConnection.ConnectionString%2A>.
|
||
|
|
||
|
To connect to a local computer, specify "(local)" for the server. If a server name is not specified, a connection will be attempted to the default instance on the local computer.
|
||
|
|
||
|
Resetting the <xref:Microsoft.Data.SqlClient.SqlConnection.ConnectionString%2A> on a closed connection resets all connection string values (and related properties) including the password. For example, if you set a connection string that includes "Database= AdventureWorks", and then reset the connection string to "Data Source=myserver;Integrated Security=true", the <xref:Microsoft.Data.SqlClient.SqlConnection.Database%2A> property is no longer set to "AdventureWorks".
|
||
|
|
||
|
The connection string is parsed immediately after being set. If errors in syntax are found when parsing, a runtime exception, such as <xref:System.ArgumentException>, is generated. Other errors can be found only when an attempt is made to open the connection.
|
||
|
|
||
|
The basic format of a connection string includes a series of keyword/value pairs separated by semicolons. The equal sign (=) connects each keyword and its value. To include values that contain a semicolon, single-quote character, or double-quote character, the value must be enclosed in double quotation marks. If the value contains both a semicolon and a double-quote character, the value can be enclosed in single quotation marks. The single quotation mark is also useful if the value starts with a double-quote character. Conversely, the double quotation mark can be used if the value starts with a single quotation mark. If the value contains both single-quote and double-quote characters, the quotation mark character used to enclose the value must be doubled every time it occurs within the value.
|
||
|
|
||
|
To include preceding or trailing spaces in the string value, the value must be enclosed in either single quotation marks or double quotation marks. Any leading or trailing spaces around integer, Boolean, or enumerated values are ignored, even if enclosed in quotation marks. However, spaces within a string literal keyword or value are preserved. Single or double quotation marks may be used within a connection string without using delimiters (for example, Data Source= my'Server or Data Source= my"Server), unless a quotation mark character is the first or last character in the value.
|
||
|
|
||
|
Keywords are not case sensitive.
|
||
|
|
||
|
The following table lists the valid names for keyword values within the <xref:Microsoft.Data.SqlClient.SqlConnection.ConnectionString%2A>.
|
||
|
|
||
|
|Keyword|Default|Description|
|
||
|
|-------------|-------------|-----------------|
|
||
|
|Addr|N/A|Synonym of **Data Source**.|
|
||
|
|Address|N/A|Synonym of **Data Source**.|
|
||
|
|App|N/A|Synonym of **Application Name**.|
|
||
|
|Application Intent<br /><br /> -or-<br /><br />ApplicationIntent|ReadWrite|Declares the application workload type when connecting to a server. Possible values are `ReadOnly` and `ReadWrite`. For example:<br /><br /> `ApplicationIntent=ReadOnly`<br /><br /> For more information about SqlClient support for Always On Availability Groups, see [SqlClient Support for High Availability, Disaster Recovery](/sql/connect/ado-net/sql/sqlclient-support-high-availability-disaster-recovery).|
|
||
|
|Application Name|N/A|The name of the application. If no application name is provided, 'Framework Microsoft SqlClient Data Provider' when running on .NET Framework and 'Core Microsoft SqlClient Data Provider' otherwise.<br /><br /> An application name can be 128 characters or less.|
|
||
|
|AttachDBFilename<br /><br /> -or-<br /><br /> Extended Properties<br /><br /> -or-<br /><br /> Initial File Name|N/A|The name of the primary database file, including the full path name of an attachable database. AttachDBFilename is only supported for primary data files with an .mdf extension.<br /><br /> If the value of the AttachDBFileName key is specified in the connection string, the database is attached and becomes the default database for the connection.<br /><br /> If this key is not specified and if the database was previously attached, the database will not be reattached. The previously attached database will be used as the default database for the connection.<br /><br /> If this key is specified together with the AttachDBFileName key, the value of this key will be used as the alias. However, if the name is already used in another attached database, the connection will fail.<br /><br /> The path may be absolute or relative by using the DataDirectory substitution string. If DataDirectory is used, the database file must exist within a subdirectory of the directory pointed to by the substitution string. **Note:** Remote server, HTTP, and UNC path names are not supported. <br /><br /> The database name must be specified with the keyword 'database' (or one of its aliases) as in the following:<br /><br /> <code>"AttachDbFileName=|DataDirectory|\data\YourDB.mdf;integrated security=true;database=YourDatabase"</code><br /><br /> An error will be generated if a log file exists in the same directory as the data file and the 'database' keyword is used when attaching the primary data file. In this case, remove the log file. Once the database is attached, a new log file will be automatically generated based on the physical path.|
|
||
|
|Attestation Protocol|NotSpecified|Gets or sets the value of Attestation Protocol.<br /><br />When no value is specified, secure enclaves are disabled on the connection.<br /><br />Valid values are:<br />`AAS`<br />`HGS`<br />`None` (Only valid in v3.1 and v4.1+))|
|
||
|
|Authentication|N/A|The authentication method used for [Connecting to SQL Database By Using Azure Active Directory Authentication](https://azure.microsoft.com/documentation/articles/sql-database-aad-authentication/#7-connect-to-your-database-by-using-azure-active-directory-identities).<br /><br /> Valid values are:<br /><br /> `Active Directory Integrated`, `Active Directory Interactive`, `Active Directory Password`, `Active Directory Service Principal`, `Active Directory Device Code Flow`, `Active Directory Managed Identity`, `Active Directory MSI`, `Active Directory Default`, `Sql Password`.<br /><br /> For additional information see [Using Azure Active Directory authentication with SqlClient](https://docs.microsoft.com/sql/connect/ado-net/sql/azure-active-directory-authentication?view=sql-server-ver15).|
|
||
|
|Column Encryption Setting|disabled|Enables or disables [Always Encrypted](/sql/relational-databases/security/encryption/always-encrypted-database-engine) functionality for the connection. Supported values are: `enabled` and `disabled`|
|
||
|
|Command Timeout|30|The default wait time (in seconds) before terminating the attempt to execute a command and generating an error.<br /><br /> Valid values are greater than or equal to 0 and less than or equal to 2147483647.|
|
||
|
|Connect Retry Count<br /><br /> -or-<br /><br />ConnectRetryCount|1|Controls the number of reconnection attempts after the client identifies an idle connection failure. Valid values are 0 to 255. 0 means do not attempt to reconnect (disable connection resiliency).<br /><br /> Note: Since version 5.x the default value for non Azure endpoints is 1. For Azure SQL endpoints, the default is 2. For Azure SQL serverless or on demand endpoints, the default is 5 to improve connection success for connections to an idle or paused instance.<br /><br /> For additional information about idle connection resiliency, see [.NET SqlConnection parameters for connection retry](https://learn.microsoft.com/azure/azure-sql/database/troubleshoot-common-connectivity-issues?view=azuresql#net-sqlconnection-parameters-for-connection-retry) and [Technical Article - Idle Connection Resiliency](https://go.microsoft.com/fwlink/?LinkId=393996).|
|
||
|
|Connect Retry Interval<br /><br /> -or-<br /><br />ConnectRetryInterval|10|Specifies the time between each connection retry attempt (`ConnectRetryCount`). Valid values are 1 to 60 seconds (default=10), applied after the first reconnection attempt. When a broken connection is detected, the client immediately attempts to reconnect; this is the first reconnection attempt and only occurs if `ConnectRetryCount` is greater than 0. If the first reconnection attempt fails and `ConnectRetryCount` is greater than 1, the client waits `ConnectRetryInterval` to try the second and subsequent reconnection attempts.<br /><br /> For additional information about idle connection resiliency, see[.NET SqlConnection parameters for connection retry](https://learn.microsoft.com/azure/azure-sql/database/troubleshoot-common-connectivity-issues?view=azuresql#net-sqlconnection-parameters-for-connection-retry) and [Technical Article - Idle Connection Resiliency](https://go.microsoft.com/fwlink/?LinkId=393996).|
|
||
|
|Connect Timeout<br /><br /> -or-<br /><br /> Connection Timeout<br /><br /> -or-<br /><br /> Timeout|15|The length of time (in seconds) to wait for a connection to the server before terminating the attempt and generating an error.<br /><br /> Valid values are greater than or equal to 0 and less than or equal to 2147483647.<br /><br /> When opening a connection to a Azure SQL Database, set the connection timeout to 30 seconds.|
|
||
|
|Current Language<br /><br /> -or-<br /><br /> Language|N/A|Sets the language used for database server warning or error messages.<br /><br /> The language name can be 128 characters or less.|
|
||
|
|Data Source<br /><br /> -or-<br /><br /> Server<br /><br /> -or-<br /><br /> Address<br /><br /> -or-<br /><br /> Addr<br /><br /> -or-<br /><br /> Network Address|N/A|The name or network address of the instance of SQL Server to which to connect. The port number can be specified after the server name:<br /><br /> `server=tcp:servername, portnumber`<br /><br /> When specifying a local instance, always use (local). To force a protocol, add one of the following prefixes:<br /><br /> `np:(local), tcp:(local), lpc:(local)`<br /><br /> You can also connect to a LocalDB database as follows:<br /><br /> `server=(localdb)\\myInstance`<br /><br /> For more information about LocalDB, see [SqlClient Support for LocalDB](/sql/connect/ado-net/sql/sqlclient-support-localdb).<br /><br /> **Data Source** must use the TCP format or the Named Pipes format.<br /><br /> TCP format is as follows:<br /><br /> - tcp:\<host name>\\<instance name\><br />- tcp:\<host name>,\<TCP/IP port number><br /><br /> The TCP format must start with the prefix "tcp:" and is followed by the database instance, as specified by a host name and an instance name. This format is not applicable when connecting to Azure SQL Database. TCP is automatically selected for connections to Azure SQL Database when no protocol is specified.<br /><br /> The host name MUST be specified in one of the following ways:<br /><br /> - NetBIOSName<br />- IPv4Address<br />- IPv6Address<br /><br /> The instance name is used to resolve to a particular TCP/IP port number on which a database instance is hosted. Alternatively, specifying a TCP/IP port number directly is also allowed. If both instance name and port number are not present, the default database instance is used.<br /><br /> The Named Pipes format is as follows:<br /><br /> - np:\\\\<host name\>\pipe\\<pipe name\><br /><br /> The Named Pipes format MUST start with the prefix "np:" and is followed by a named pipe name.<br /><br /> The host name MUST be specified in one of the following ways:<br /><br /> - NetBIOSName<br />- IPv4Address<br />- IPv6Address<br /><br /> The pipe name is used to identify the database instance to which the .NET application will connect.<br /><br /> If the value of the **Network** key is specified, the prefixes "tcp:" and "np:" should not be specified. **Note:** You can force the use of TCP instead of shared memory, either by prefixing **tcp:** to the server name in the connection string, or by using **localhost**.|
|
||
|
|Enclave Attestation Url|N/A|Gets or sets the enclave attestation URL to be used with enclave based Always Encrypted.|
|
||
|
|Encrypt|'true' in 4.0 and above<br/><br/>'false' in 3.x and below|Recognized values are:<br/>versions 1 - 4: `true`/`yes` and `false`/`no`<br/>versions 5+: `true`/`yes`/`mandatory`, `false`/`no`/`optional` and `strict`. When `true`, TLS encryption is used for all data sent between the client and server if the server has a certificate installed. When `strict`, TDS 8.0 TLS encryption is used and the `TrustServerCertificate` setting is ignored and treated as false. For more information, see [Connection String Syntax](/sql/connect/ado-net/connection-string-syntax).<br /><br /> When `Encrypt` is `mandatory` or `strict` and `TrustServerCertificate` is `false`, the server name (or IP address) in a server's certificate must exactly match the server name (or IP address) specified in the connection string. Otherwise, the connection attempt will fail. |
|
||
|
|Enlist|'true'|`true` indicates that the SQL Server connection pooler automatically enlists the connection in the creation thread's current transaction context.|
|
||
|
|Failover Partner|N/A|The name of the failover partner server where database mirroring is configured.<br /><br /> If the value of this key is "", then **Initial Catalog** must be present, and its value must not be "".<br /><br /> The server name can be 128 characters or less.<br /><br /> If you specify a failover partner but the failover partner server is not configured for database mirroring and the primary server (specified with the Server keyword) is not available, then the connection will fail.<br /><br /> If you specify a failover partner and the primary server is not configured for database mirroring, the connection to the primary server (specified with the Server keyword) will succeed if the primary server is available.|
|
||
|
|Failover Partner SPN<br /><br /> -or-<br /><br /> FailoverPartnerSPN|N/A|The SPN for the failover partner. The default value is an empty string, which causes SqlClient to use the default, driver-generated SPN.<br /><br /> (Only available in v5.0+)|
|
||
|
|Host Name In Certificate<br /><br /> -or-<br /><br />HostNameInCertificate|N/A|The host name to use when validating the server certificate. When not specified, the server name from the Data Source is used for certificate validation.<br /><br /> (Only available in v5.0+)|
|
||
|
|Server Certificate<br /><br /> -or-<br /><br />ServerCertificate|N/A|The path to a certificate file to match against the SQL Server TLS/SSL certificate. The accepted certificate formats are PEM, DER, and CER. If specified, the SQL Server certificate is checked by verifying if the ServerCertificate provided is an exact match.<br /><br /> (Only available in v5.1+)|
|
||
|
|Initial Catalog<br /><br /> -or-<br /><br /> Database|N/A|The name of the database.<br /><br /> The database name can be 128 characters or less.|
|
||
|
|Integrated Security<br /><br /> -or-<br /><br /> Trusted_Connection|'false'|When `false`, User ID and Password are specified in the connection. When `true`, the current Windows account credentials are used for authentication.<br /><br /> Recognized values are `true`, `false`, `yes`, `no`, and `sspi` (strongly recommended), which is equivalent to `true`.<br /><br /> If User ID and Password are specified and Integrated Security is set to true, the User ID and Password will be ignored and Integrated Security will be used.<br /><br /> <xref:Microsoft.Data.SqlClient.SqlCredential> is a more secure way to specify credentials for a connection that uses SQL Server Authentication (`Integrated Security=false`).|
|
||
|
|IP Address Preference<br /><br /> -or-<br /><br /> IPAddressPreference|IPv4First|The IP address family preference when establishing TCP connections. If `Transparent Network IP Resolution` (in .NET Framework) or `Multi Subnet Failover` is set to true, this setting has no effect. Supported values include:<br /><br /> `IPAddressPreference=IPv4First`<br /><br />`IPAddressPreference=IPv6First`<br /><br />`IPAddressPreference=UsePlatformDefault`|
|
||
|
|Load Balance Timeout<br /><br /> -or-<br /><br /> Connection Lifetime|0|When a connection is returned to the pool, its creation time is compared with the current time, and the connection is destroyed if that time span (in seconds) exceeds the value specified by `Connection Lifetime`. This is useful in clustered configurations to force load balancing between a running server and a server just brought online.<br /><br /> A value of zero (0) causes pooled connections to have the maximum connection timeout.|
|
||
|
|Max Pool Size|100|The maximum number of connections that are allowed in the pool.<br /><br /> Valid values are greater than or equal to 1. Values that are less than **Min Pool Size** generate an error.|
|
||
|
|Min Pool Size|0|The minimum number of connections that are allowed in the pool.<br /><br /> Valid values are greater than or equal to 0. Zero (0) in this field means no minimum connections are initially opened.<br /><br /> Values that are greater than **Max Pool Size** generate an error.|
|
||
|
|Multiple Active Result Sets<br /><br /> -or-<br /><br />MultipleActiveResultSets|false|When `true`, an application can maintain multiple active result sets (MARS). When `false`, an application must process or cancel all result sets from one batch before it can execute any other batch on that connection.<br /><br /> Recognized values are `true` and `false`.<br /><br /> For more information, see [Multiple Active Result Sets (MARS)](/sql/connect/ado-net/sql/multiple-active-result-sets-mars).|
|
||
|
|Multi Subnet Failover<br /><br /> -or-<br /><br />MultiSubnetFailover|false|Always specify `multiSubnetFailover=True` when connecting to the availability group listener of a SQL Server 2012 (or later) availability group or a SQL Server 2012 (or later) Failover Cluster Instance. `multiSubnetFailover=True` configures SqlClient to provide faster detection of and connection to the (currently) active server. Possible values are `Yes` and `No`, `True` and `False` or `1` and `0`. For example:<br /><br /> `MultiSubnetFailover=True`<br /><br /> The default is `False`. For more information about SqlClient's support for Always On AGs, see [SqlClient Support for High Availability, Disaster Recovery](/sql/connect/ado-net/sql/sqlclient-support-high-availability-disaster-recovery).|
|
||
|
|Network Library<br /><br /> -or-<br /><br /> Network<br /><br /> -or-<br /><br /> Net|N/A|The network library used to establish a connection to an instance of SQL Server. Supported values include:<br /><br /> dbnmpntw (Named Pipes)<br /><br /> dbmsrpcn (Multiprotocol, Windows RPC)<br /><br /> dbmsadsn (Apple Talk)<br /><br /> dbmsgnet (VIA)<br /><br /> dbmslpcn (Shared Memory)<br /><br /> dbmsspxn (IPX/SPX)<br /><br /> dbmssocn (TCP/IP)<br /><br /> Dbmsvinn (Banyan Vines)<br /><br /> The corresponding network DLL must be installed on the system to which you connect. If you do not specify a network and you use a local server (for example, "." or "(local)"), shared memory is used. In this example, the network library is Win32 Winsock TCP/IP (dbmssocn), and 1433 is the port being used.<br /><br /> `Network Library=dbmssocn;Data Source=000.000.000.000,1433;`|
|
||
|
|Packet Size|8000|Size in bytes of the network packets used to communicate with an instance of SQL Server.<br /><br /> The packet size can be greater than or equal to 512 and less than or equal to 32768.|
|
||
|
|Password<br /><br /> -or-<br /><br /> PWD|N/A|The password for the SQL Server account logging on. Not recommended. To maintain a high level of security, we strongly recommend that you use the `Integrated Security` or `Trusted_Connection` keyword instead. <xref:Microsoft.Data.SqlClient.SqlCredential> is a more secure way to specify credentials for a connection that uses SQL Server Authentication.<br /><br /> The password must be 128 characters or less.|
|
||
|
|Persist Security Info<br /><br /> -or-<br /><br /> PersistSecurityInfo|'false'|When set to `false` or `no` (strongly recommended), security-sensitive information, such as the password or access token, is not returned as part of the connection if the connection is open or has ever been in an open state. This property should only be set to `true` if your application has a specific need to read the password out of an already-opened database connection. The default value of `false` is the more secure setting; using `true` for this property opens your application to security risks such as accidentally logging or tracing the database password.<br /><br />Resetting the connection string resets all connection string values including the password. Recognized values are `true`, `false`, `yes`, and `no`.|
|
||
|
|Pool Blocking Period<br /><br /> -or-<br /><br />PoolBlockingPeriod|Auto|Sets the blocking period behavior for a connection pool. See <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.PoolBlockingPeriod> property for details.|
|
||
|
|Pooling|'true'|When the value of this key is set to true, any newly created connection will be added to the pool when closed by the application. In a next attempt to open the same connection, that connection will be drawn from the pool.<br /><br /> Connections are considered the same if they have the same connection string. Different connections have different connection strings.<br /><br /> The value of this key can be "true", "false", "yes", or "no".|
|
||
|
|Replication|'false'|`true` if replication is supported using the connection.|
|
||
|
|Server SPN<br /><br /> -or-<br /><br /> ServerSPN|N/A|The SPN for the data source. The default value is an empty string, which causes SqlClient to use the default, driver-generated SPN.<br /><br /> (Only available in v5.0+)|
|
||
|
|Transaction Binding|Implicit Unbind|Controls connection association with an enlisted `System.Transactions` transaction.<br /><br /> Possible values are:<br /><br /> `Transaction Binding=Implicit Unbind;`<br /><br /> `Transaction Binding=Explicit Unbind;`<br /><br /> Implicit Unbind causes the connection to detach from the transaction when it ends. After detaching, additional requests on the connection are performed in autocommit mode. The `System.Transactions.Transaction.Current` property is not checked when executing requests while the transaction is active. After the transaction has ended, additional requests are performed in autocommit mode.<br /><br /> If the system ends the transaction (in the scope of a using block) before the last command completes, it will throw <xref:System.InvalidOperationException>.<br /><br /> Explicit Unbind causes the connection to remain attached to the transaction until the connection is closed or an explicit `SqlConnection.TransactionEnlist(null)` is called. Beginning in .NET Framework 4.0, changes to Implicit Unbind make Explicit Unbind obsolete. An `InvalidOperationException` is thrown if `Transaction.Current` is not the enlisted transaction or if the enlisted transaction is not active.|
|
||
|
|Transparent Network IP Resolution<br /><br /> -or-<br /><br />TransparentNetworkIPResolution|See description.|When the value of this key is set to `true`, the application is required to retrieve all IP addresses for a particular DNS entry and attempt to connect with the first one in the list. If the connection is not established within 0.5 seconds, the application will try to connect to all others in parallel. When the first answers, the application will establish the connection with the respondent IP address.<br /><br /> If the `MultiSubnetFailover` key is set to `true`, `TransparentNetworkIPResolution` is ignored.<br /><br /> If the `Failover Partner` key is set, `TransparentNetworkIPResolution` is ignored.<br /><br /> The value of this key must be `true`, `false`, `yes`, or `no`.<br /><br /> A value of `yes` is treated the same as a value of `true`.<br /><br /> A value of `no` is treated the same as a value of `false`.<br /><br /> The default values are as follows:<br /><br /> <ul><li>`false` when:<br /><br /> <ul><li>Connecting to Azure SQL Database where the data source ends with:<br /><br /> <ul><li>.database.chinacloudapi.cn</li><li>.database.usgovcloudapi.net</li><li>.database.cloudapi.de</li><li>.database.windows.net</li></ul></li><li>`Authentication` is 'Active Directory Password' or 'Active Directory Integrated'</li></ul></li><li>`true` in all other cases.</li></ul>|
|
||
|
|Trust Server Certificate<br /><br /> -or-<br /><br />TrustServerCertificate|'false'|When set to `true`, TLS is used to encrypt the channel when bypassing walking the certificate chain to validate trust. If TrustServerCertificate is set to `true` and Encrypt is set to `false`, the channel is not encrypted. Recognized values are `true`, `false`, `yes`, and `no`. For more information, see [Connection String Syntax](/sql/connect/ado-net/connection-string-syntax).|
|
||
|
|Type System Version|N/A|A string value that indicates the type system the application expects. The functionality available to a client application is dependent on the version of SQL Server and the compatibility level of the database. Explicitly setting the type system version that the client application was written for avoids potential problems that could cause an application to break if a different version of SQL Server is used. **Note:** The type system version cannot be set for common language runtime (CLR) code executing in-process in SQL Server. For more information, see [SQL Server Common Language Runtime Integration](/dotnet/framework/data/adonet/sql/sql-server-common-language-runtime-integration). <br /><br /> Possible values are:<br /><br /> `Type System Version=SQL Server 2012;`<br /><br /> `Type System Version=SQL Server 2008;`<br /><br /> `Type System Version=SQL Server 2005;`<br /><br /> `Type System Version=Latest;`<br /><br /> `Type System Version=SQL Server 2012;` specifies that the application will require version 11.0.0.0 of Microsoft.SqlServer.Types.dll. The other `Type System Version` settings will require version 10.0.0.0 of Microsoft.SqlServer.Types.dll.<br /><br /> `Latest` is obsolete and should not be used. `Latest` is equivalent to `Type System Version=SQL Server 2008;`.|
|
||
|
|User ID<br /><br /> -or-<br /><br /> UID<br /><br /> -or-<br /><br /> User|N/A|The SQL Server login account. Not recommended. To maintain a high level of security, we strongly recommend that you use the `Integrated Security` or `Trusted_Connection` keywords instead. <xref:Microsoft.Data.SqlClient.SqlCredential> is a more secure way to specify credentials for a connection that uses SQL Server Authentication.<br /><br /> The user ID must be 128 characters or less.|
|
||
|
|User Instance|'false'|A value that indicates whether to redirect the connection from the default SQL Server Express instance to a runtime-initiated instance running under the account of the caller.|
|
||
|
|Workstation ID<br /><br /> -or-<br /><br /> WSID|The local computer name|The name of the workstation connecting to SQL Server.<br /><br /> The ID must be 128 characters or less.|
|
||
|
|
||
|
The following list contains the valid names for connection pooling values within the <xref:Microsoft.Data.SqlClient.SqlConnection.ConnectionString%2A>. For more information, see [SQL Server Connection Pooling (ADO.NET)](/sql/connect/ado-net/sql-server-connection-pooling).
|
||
|
|
||
|
- Connection Lifetime (or Load Balance Timeout)
|
||
|
|
||
|
- Enlist
|
||
|
|
||
|
- Max Pool Size
|
||
|
|
||
|
- Min Pool Size
|
||
|
|
||
|
- Pooling
|
||
|
|
||
|
When you are setting keyword or connection pooling values that require a Boolean value, you can use 'yes' instead of 'true', and 'no' instead of 'false'. Integer values are represented as strings.
|
||
|
> [!NOTE]
|
||
|
> The .NET Framework Data Provider for SQL Server uses its own protocol to communicate with SQL Server. Therefore, it does not support the use of an ODBC data source name (DSN) when connecting to SQL Server because it does not add an ODBC layer.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> Universal data link (UDL) files are not supported for the .NET Framework Data Provider for SQL Server.
|
||
|
|
||
|
> [!CAUTION]
|
||
|
> In this release, the application should use caution when constructing a connection string based on user input (for example when retrieving user ID and password information from a dialog box, and appending it to the connection string). The application should make sure that a user cannot embed additional connection string parameters in these values (for example, entering a password as "validpassword;database=somedb" in an attempt to attach to a different database). If you need to construct connection strings based on user input, use the new <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder>, which validates the connection string and helps to eliminate this problem. See [Connection String Builders](/sql/connect/ado-net/connection-string-builders) for more information.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlConnection> and sets the <xref:Microsoft.Data.SqlClient.SqlConnection.ConnectionString%2A> property before opening the connection.
|
||
|
|
||
|
[!code-csharp[SqlConnection_ConnectionString Example#1](~/../sqlclient/doc/samples/SqlConnection_ConnectionString.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentException">An invalid connection string argument has been supplied, or a required connection string argument has not been supplied.</exception>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnection.ConnectionTimeout">
|
||
|
<summary>Gets the time to wait while trying to establish a connection before terminating the attempt and generating an error.</summary><value>The time (in seconds) to wait for a connection to open. The default value is 15 seconds.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
You can set the amount of time a connection waits to time out by using the `Connect Timeout` or `Connection Timeout` keywords in the connection string. A value of 0 indicates no limit, and should be avoided in a <xref:Microsoft.Data.SqlClient.SqlConnection.ConnectionString%2A> because an attempt to connect waits indefinitely.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlConnection> and sets the `Connection Timeout` to 30 seconds in the connection string. The code opens the connection and displays the <xref:Microsoft.Data.SqlClient.SqlConnection.ConnectionTimeout%2A> property in the console window.
|
||
|
|
||
|
[!code-csharp[SqlConnection_ConnectionTimeout Example#1](~/../sqlclient/doc/samples/SqlConnection_ConnectionTimeout.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentException">The value set is less than 0.</exception>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnection.Credential">
|
||
|
<summary>Gets or sets the <see cref="T:Microsoft.Data.SqlClient.SqlCredential" /> object for this connection.</summary><value>The <see cref="T:Microsoft.Data.SqlClient.SqlCredential" /> object for this connection.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
`Persist Security Info = true` is required to get the value of the <xref:Microsoft.Data.SqlClient.SqlCredential> object with <xref:Microsoft.Data.SqlClient.SqlConnection.Credential%2A>.
|
||
|
|
||
|
The default value of <xref:Microsoft.Data.SqlClient.SqlConnection.Credential%2A> is null.
|
||
|
|
||
|
An <xref:System.InvalidOperationException> exception will be raised:
|
||
|
|
||
|
- If <xref:Microsoft.Data.SqlClient.SqlConnection.Credential%2A> is set on an open connection.
|
||
|
|
||
|
- If <xref:Microsoft.Data.SqlClient.SqlConnection.Credential%2A> is set when `Integrated Security = true`.
|
||
|
|
||
|
- If <xref:Microsoft.Data.SqlClient.SqlConnection.Credential%2A> is set when the connection string uses `Password`.
|
||
|
|
||
|
- If <xref:Microsoft.Data.SqlClient.SqlConnection.Credential%2A> is set when the connection string uses `UserID`.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnection.Database">
|
||
|
<summary>Gets the name of the current database or the database to be used after a connection is opened.</summary><value>The name of the current database or the name of the database to be used after a connection is opened. The default value is an empty string.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlConnection.Database%2A> property updates dynamically. If you change the current database using a Transact-SQL statement or the <xref:Microsoft.Data.SqlClient.SqlConnection.ChangeDatabase%2A> method, an informational message is sent and the property is updated automatically.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlConnection> and displays some of its read-only properties.
|
||
|
|
||
|
[!code-csharp[SqlConnection_Database Example#1](~/../sqlclient/doc/samples/SqlConnection_Database.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnection.DataSource">
|
||
|
<summary>Gets the name of the instance of SQL Server to which to connect.</summary><value>The name of the instance of SQL Server to which to connect. The default value is an empty string.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlConnection> and displays some of its read-only properties.
|
||
|
|
||
|
[!code-csharp[SqlConnection_DataSource Example#1](~/../sqlclient/doc/samples/SqlConnection_DataSource.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnection.FireInfoMessageEventOnUserErrors">
|
||
|
<summary>Gets or sets the <see cref="P:Microsoft.Data.SqlClient.SqlConnection.FireInfoMessageEventOnUserErrors" /> property.</summary><value>
|
||
|
<see langword="true" /> if the <see cref="P:Microsoft.Data.SqlClient.SqlConnection.FireInfoMessageEventOnUserErrors" /> property has been set; otherwise <see langword="false" />.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
When you set <xref:Microsoft.Data.SqlClient.SqlConnection.FireInfoMessageEventOnUserErrors%2A> to `true`, errors that were previously treated as exceptions are now handled as <xref:Microsoft.Data.SqlClient.SqlConnection.InfoMessage> events. All events fire immediately and are handled by the event handler. If is <xref:Microsoft.Data.SqlClient.SqlConnection.FireInfoMessageEventOnUserErrors%2A> is set to `false`, then <xref:Microsoft.Data.SqlClient.SqlConnection.InfoMessage> events are handled at the end of the procedure.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> An error with a severity level of 17 or above that causes the server to stop processing the command needs to be handled as an exception. In this case, an exception is thrown regardless of how the error is handled in the <xref:Microsoft.Data.SqlClient.SqlConnection.InfoMessage> event.
|
||
|
|
||
|
For more information on working with events, see [Connection Events](/sql/connect/ado-net/connection-events). For more information on errors generated by the SQL Server engine, see [Database Engine Errors](/sql/relational-databases/errors-events/database-engine-events-and-errors).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnection.PacketSize">
|
||
|
<summary>Gets the size (in bytes) of network packets used to communicate with an instance of SQL Server.</summary><value>The size (in bytes) of network packets. The default value is 8000.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
If an application performs bulk copy operations, or sends or receives lots of text or image data, a packet size larger than the default may improve efficiency because it causes fewer network read and write operations. If an application sends and receives small amounts of information, you can set the packet size to 512 bytes (using the Packet Size value in the <xref:Microsoft.Data.SqlClient.SqlConnection.ConnectionString%2A>), which is sufficient for most data transfer operations. For most applications, the default packet size is best.
|
||
|
|
||
|
<xref:Microsoft.Data.SqlClient.SqlConnection.PacketSize%2A> may be a value in the range of 512 and 32767 bytes. An exception is generated if the value is outside this range.
|
||
|
|
||
|
Setting the default value to a number greater than 8000 will cause the packets to use the MultiPage allocator on the instance of SQL Server instead of the much more efficient SinglePage allocator, reducing the overall scalability of the SQL Server. For more information on how SQL Server uses memory, see [Memory Management Architecture Guide](/sql/relational-databases/memory-management-architecture-guide).
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlConnection>, including setting the `Packet Size` to 512 in the connection string. It displays the <xref:Microsoft.Data.SqlClient.SqlConnection.PacketSize%2A> and <xref:Microsoft.Data.SqlClient.SqlConnection.ServerVersion%2A> properties in the console window.
|
||
|
|
||
|
[!code-csharp[SqlConnection_PacketSize Example#1](~/../sqlclient/doc/samples/SqlConnection_PacketSize.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnection.ServerVersion">
|
||
|
<summary>Gets a string that contains the version of the instance of SQL Server to which the client is connected.</summary><value>The version of the instance of SQL Server.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The version is of the form *##.##.####*, where the first two digits are the major version, the next two digits are the minor version, and the last four digits are the release version. The string is of the form *major.minor.build*, where major and minor are exactly two digits and build is exactly four digits.
|
||
|
|
||
|
<xref:Microsoft.Data.SqlClient.SqlConnection.ServerVersion%2A> was called while the returned Task was not completed and the connection was not opened after a call to <xref:Microsoft.Data.SqlClient.SqlConnection.OpenAsync%2A>.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlConnection> and displays the <xref:Microsoft.Data.SqlClient.SqlConnection.ServerVersion%2A> property.
|
||
|
|
||
|
[!code-csharp[SqlConnection_ServerVersion Example#1](~/../sqlclient/doc/samples/SqlConnection_ServerVersion.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidOperationException">The connection is closed.
|
||
|
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlConnection.ServerVersion" /> was called while the returned Task was not completed and the connection was not opened after a call to <see cref="M:Microsoft.Data.SqlClient.SqlConnection.OpenAsync(System.Threading.CancellationToken)" />.</exception>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnection.ServerProcessId">
|
||
|
<summary>Gets the server process Id (SPID) of the active connection.</summary><value>The server process Id (SPID) of the active connection.</value><remarks>Returns 0 if the connection is inactive on the client side.</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnection.State">
|
||
|
<summary>Indicates the state of the <see cref="T:Microsoft.Data.SqlClient.SqlConnection" /> during the most recent network operation performed on the connection.</summary><value>An <see cref="T:System.Data.ConnectionState" /> enumeration.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Returns an <xref:System.Data.ConnectionState> enumeration indicating the state of the <xref:Microsoft.Data.SqlClient.SqlConnection>. Closing and reopening the connection will refresh the value of <xref:Microsoft.Data.SqlClient.SqlConnection.State%2A>.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnection.StatisticsEnabled">
|
||
|
<summary>When set to <see langword="true" />, enables statistics gathering for the current connection.</summary><value>Returns <see langword="true" /> if statistics gathering is enabled; otherwise <see langword="false" />. <see langword="false" /> is the default.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Enabling statistics gathering has a minor, but measurable effect on performance and therefore should be enabled only when it is required.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnection.WorkstationId">
|
||
|
<summary>Gets a string that identifies the database client.</summary><value>A string that identifies the database client. If not specified, the name of the client computer. If neither is specified, the value is an empty string.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The string typically contains the network name of the client. The <xref:Microsoft.Data.SqlClient.SqlConnection.WorkstationId%2A> property corresponds to the `Workstation ID` connection string property.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlConnection> and displays the <xref:Microsoft.Data.SqlClient.SqlConnection.WorkstationId%2A> property.
|
||
|
|
||
|
[!code-csharp[SqlConnection_WorkstationId Example#1](~/../sqlclient/doc/samples/SqlConnection_WorkstationId.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="E:Microsoft.Data.SqlClient.SqlConnection.InfoMessage">
|
||
|
<summary>Occurs when SQL Server returns a warning or informational message.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Clients that want to process warnings or informational messages sent by the server should create an <xref:Microsoft.Data.SqlClient.SqlInfoMessageEventHandler> delegate to listen to this event.
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlConnection.InfoMessage> event occurs when a message with a severity of 10 or less is returned by SQL Server. Messages that have a severity between 11 and 20 raise an error and messages that have a severity over 20 causes the connection to close. For more information on SQL Server error levels, see [Database Engine Error Severities](/sql/relational-databases/errors-events/database-engine-error-severities).
|
||
|
|
||
|
For more information and an example, see [Connection Events](/sql/connect/ado-net/connection-events).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnection.BeginDbTransaction(System.Data.IsolationLevel)">
|
||
|
<param name="isolationLevel">To be added.</param><summary>To be added.</summary><returns>To be added.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnection.BeginTransaction">
|
||
|
<summary>Starts a database transaction.</summary><returns>An object representing the new transaction.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This command maps to the SQL Server implementation of BEGIN TRANSACTION.
|
||
|
|
||
|
You must explicitly commit or roll back the transaction using the <xref:Microsoft.Data.SqlClient.SqlTransaction.Commit%2A> or <xref:Microsoft.Data.SqlClient.SqlTransaction.Rollback%2A> method. To make sure that the .NET Framework Data Provider for SQL Server transaction management model performs correctly, avoid using other transaction management models, such as the one provided by SQL Server.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> If you do not specify an isolation level, the default isolation level is used. To specify an isolation level with the <xref:Microsoft.Data.SqlClient.SqlConnection.BeginTransaction%2A> method, use the overload that takes the `iso` parameter (<xref:Microsoft.Data.SqlClient.SqlConnection.BeginTransaction%2A>). The isolation level set for a transaction persists after the transaction is completed and until the connection is closed or disposed. Setting the isolation level to **Snapshot** in a database where the snapshot isolation level is not enabled does not throw an exception. The transaction will complete using the default isolation level.
|
||
|
|
||
|
> [!CAUTION]
|
||
|
> If a transaction is started and a level 16 or higher error occurs on the server, the transaction will not be rolled back until the <xref:Microsoft.Data.SqlClient.SqlDataReader.Read%2A> method is invoked. No exception is thrown on **ExecuteReader**.
|
||
|
|
||
|
> [!CAUTION]
|
||
|
> When your query returns a large amount of data and calls `BeginTransaction`, a <xref:Microsoft.Data.SqlClient.SqlException> is thrown because SQL Server does not allow parallel transactions when using MARS. To avoid this problem, always associate a transaction with the command, the connection, or both before any readers are open.
|
||
|
|
||
|
For more information on SQL Server transactions, see [Transactions (Transact-SQL)](/sql/t-sql/language-elements/transactions-transact-sql).
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlConnection> and a <xref:Microsoft.Data.SqlClient.SqlTransaction>. It also demonstrates how to use the <xref:Microsoft.Data.SqlClient.SqlConnection.BeginTransaction%2A>, a <xref:Microsoft.Data.SqlClient.SqlTransaction.Commit%2A>, and <xref:Microsoft.Data.SqlClient.SqlTransaction.Rollback%2A> methods.
|
||
|
|
||
|
[!code-csharp[SqlConnection_BeginTransaction Example#1](~/../sqlclient/doc/samples/SqlConnection_BeginTransaction.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:Microsoft.Data.SqlClient.SqlException">Parallel transactions are not allowed when using Multiple Active Result Sets (MARS).</exception><exception cref="T:System.InvalidOperationException">Parallel transactions are not supported.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnection.BeginTransaction(System.Data.IsolationLevel)">
|
||
|
<param name="iso">The isolation level under which the transaction should run.</param><summary>Starts a database transaction with the specified isolation level.</summary><returns>An object representing the new transaction.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This command maps to the SQL Server implementation of BEGIN TRANSACTION.
|
||
|
|
||
|
You must explicitly commit or roll back the transaction using the <xref:Microsoft.Data.SqlClient.SqlTransaction.Commit%2A> or <xref:Microsoft.Data.SqlClient.SqlTransaction.Rollback%2A> method. To make sure that the .NET Framework Data Provider for SQL Server transaction management model performs correctly, avoid using other transaction management models, such as the one provided by SQL Server.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> After a transaction is committed or rolled back, the isolation level of the transaction persists for all subsequent commands that are in autocommit mode (the SQL Server default). This can produce unexpected results, such as an isolation level of REPEATABLE READ persisting and locking other users out of a row. To reset the isolation level to the default (READ COMMITTED), execute the Transact-SQL SET TRANSACTION ISOLATION LEVEL READ COMMITTED statement, or call <xref:Microsoft.Data.SqlClient.SqlConnection.BeginTransaction%2A?displayProperty=nameWithType> followed immediately by <xref:Microsoft.Data.SqlClient.SqlTransaction.Commit%2A?displayProperty=nameWithType>. For more information on SQL Server isolation levels, see [Transaction Isolation Levels](/sql/t-sql/language-elements/transaction-isolation-levels).
|
||
|
|
||
|
For more information on SQL Server transactions, see [Transactions (Transact-SQL)](/sql/t-sql/language-elements/transactions-transact-sql).
|
||
|
|
||
|
> [!CAUTION]
|
||
|
> When your query returns a large amount of data and calls `BeginTransaction`, a <xref:Microsoft.Data.SqlClient.SqlException> is thrown because SQL Server does not allow parallel transactions when using MARS. To avoid this problem, always associate a transaction with the command, the connection, or both before any readers are open.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlConnection> and a <xref:Microsoft.Data.SqlClient.SqlTransaction>. It also demonstrates how to use the <xref:Microsoft.Data.SqlClient.SqlConnection.BeginTransaction%2A>, a <xref:Microsoft.Data.SqlClient.SqlTransaction.Commit%2A>, and <xref:Microsoft.Data.SqlClient.SqlTransaction.Rollback%2A> methods.
|
||
|
|
||
|
[!code-csharp[SqlConnection_BeginTransaction1 Example#1](~/../sqlclient/doc/samples/SqlConnection_BeginTransaction1.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:Microsoft.Data.SqlClient.SqlException">Parallel transactions are not allowed when using Multiple Active Result Sets (MARS).</exception><exception cref="T:System.InvalidOperationException">Parallel transactions are not supported.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnection.BeginTransaction(System.Data.IsolationLevel,System.String)">
|
||
|
<param name="iso">The isolation level under which the transaction should run.</param><param name="transactionName">The name of the transaction.</param><summary>Starts a database transaction with the specified isolation level and transaction name.</summary><returns>An object representing the new transaction.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This command maps to the SQL Server implementation of BEGIN TRANSACTION.
|
||
|
|
||
|
The value in the `transactionName` parameter can be used in later calls to <xref:Microsoft.Data.SqlClient.SqlTransaction.Rollback%2A> and in the `savePoint` parameter of the <xref:Microsoft.Data.SqlClient.SqlTransaction.Save%2A> method.
|
||
|
|
||
|
You must explicitly commit or roll back the transaction using the <xref:Microsoft.Data.SqlClient.SqlTransaction.Commit%2A> or <xref:Microsoft.Data.SqlClient.SqlTransaction.Rollback%2A> method. To make sure that the SQL Server transaction management model performs correctly, avoid using other transaction management models, such as the one provided by SQL Server.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> After a transaction is committed or rolled back, the isolation level of the transaction persists for all subsequent commands that are in autocommit mode (the SQL Server default). This can produce unexpected results, such as an isolation level of REPEATABLE READ persisting and locking other users out of a row. To reset the isolation level to the default (READ COMMITTED), execute the Transact-SQL SET TRANSACTION ISOLATION LEVEL READ COMMITTED statement, or call <xref:Microsoft.Data.SqlClient.SqlConnection.BeginTransaction%2A?displayProperty=nameWithType> followed immediately by <xref:Microsoft.Data.SqlClient.SqlTransaction.Commit%2A?displayProperty=nameWithType>. For more information on SQL Server isolation levels, see [Transaction Isolation Levels](/sql/t-sql/language-elements/transaction-isolation-levels).
|
||
|
|
||
|
For more information on SQL Server transactions, see [Transactions (Transact-SQL)](/sql/t-sql/language-elements/transactions-transact-sql).
|
||
|
|
||
|
> [!CAUTION]
|
||
|
> When your query returns a large amount of data and calls `BeginTransaction`, a <xref:Microsoft.Data.SqlClient.SqlException> is thrown because SQL Server does not allow parallel transactions when using MARS. To avoid this problem, always associate a transaction with the command, the connection, or both before any readers are open.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlConnection> and a <xref:Microsoft.Data.SqlClient.SqlTransaction>. It also demonstrates how to use the <xref:Microsoft.Data.SqlClient.SqlConnection.BeginTransaction%2A>, a <xref:Microsoft.Data.SqlClient.SqlTransaction.Commit%2A>, and <xref:Microsoft.Data.SqlClient.SqlTransaction.Rollback%2A> methods.
|
||
|
|
||
|
[!code-csharp[SqlConnection_BeginTransaction3 Example#1](~/../sqlclient/doc/samples/SqlConnection_BeginTransaction3.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:Microsoft.Data.SqlClient.SqlException">Parallel transactions are not allowed when using Multiple Active Result Sets (MARS).</exception><exception cref="T:System.InvalidOperationException">Parallel transactions are not supported.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnection.BeginTransaction(System.String)">
|
||
|
<param name="transactionName">The name of the transaction.</param><summary>Starts a database transaction with the specified transaction name.</summary><returns>An object representing the new transaction.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This command maps to the SQL Server implementation of BEGIN TRANSACTION.
|
||
|
|
||
|
The length of the `transactionName` parameter must not exceed 32 characters; otherwise an exception will be thrown.
|
||
|
|
||
|
The value in the `transactionName` parameter can be used in later calls to <xref:Microsoft.Data.SqlClient.SqlTransaction.Rollback%2A> and in the `savePoint` parameter of the <xref:Microsoft.Data.SqlClient.SqlTransaction.Save%2A> method.
|
||
|
|
||
|
You must explicitly commit or roll back the transaction using the <xref:Microsoft.Data.SqlClient.SqlTransaction.Commit%2A> or <xref:Microsoft.Data.SqlClient.SqlTransaction.Rollback%2A> method. To make sure that the .NET Data Provider for SQL Server transaction management model performs correctly, avoid using other transaction management models, such as the one provided by SQL Server.
|
||
|
|
||
|
For more information on SQL Server transactions, see [Transactions (Transact-SQL)](/sql/t-sql/language-elements/transactions-transact-sql).
|
||
|
|
||
|
> [!CAUTION]
|
||
|
> When your query returns a large amount of data and calls `BeginTransaction`, a <xref:Microsoft.Data.SqlClient.SqlException> is thrown because SQL Server does not allow parallel transactions when using MARS. To avoid this problem, always associate a transaction with the command, the connection, or both before any readers are open.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlConnection> and a <xref:Microsoft.Data.SqlClient.SqlTransaction>. It also demonstrates how to use the <xref:Microsoft.Data.SqlClient.SqlConnection.BeginTransaction%2A>, a <xref:Microsoft.Data.SqlClient.SqlTransaction.Commit%2A>, and <xref:Microsoft.Data.SqlClient.SqlTransaction.Rollback%2A> methods.
|
||
|
|
||
|
[!code-csharp[SqlConnection_BeginTransaction2 Example#1](~/../sqlclient/doc/samples/SqlConnection_BeginTransaction2.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:Microsoft.Data.SqlClient.SqlException">Parallel transactions are not allowed when using Multiple Active Result Sets (MARS).</exception><exception cref="T:System.InvalidOperationException">Parallel transactions are not supported.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnection.ChangeDatabase(System.String)">
|
||
|
<param name="database">The name of the database to use instead of the current database.</param><summary>Changes the current database for an open <see cref="T:Microsoft.Data.SqlClient.SqlConnection" />.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The value supplied in the `database` parameter must be a valid database name. The `database` parameter cannot contain a null value, an empty string, or a string with only blank characters.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlConnection> and displays some of its read-only properties.
|
||
|
|
||
|
[!code-csharp[SqlConnection_Database Example#1](~/../sqlclient/doc/samples/SqlConnection_Database.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentException">The database name is not valid.</exception><exception cref="T:System.InvalidOperationException">The connection is not open.</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">Cannot change the database.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnection.ChangePassword(System.String,Microsoft.Data.SqlClient.SqlCredential,System.Security.SecureString)">
|
||
|
<param name="connectionString">The connection string that contains enough information to connect to a server. The connection string should not use any of the following connection string keywords: <see langword="Integrated Security = true" />, <see langword="UserId" />, or <see langword="Password" />; or <see langword="ContextConnection = true" />.</param><param name="credential">A <see cref="T:Microsoft.Data.SqlClient.SqlCredential" /> object.</param><param name="newSecurePassword">The new password. <paramref name="newSecurePassword" /> must be read only. The password must also comply with any password security policy set on the server (for example, minimum length and requirements for specific characters).</param><summary>Changes the SQL Server password for the user indicated in the <see cref="T:Microsoft.Data.SqlClient.SqlCredential" /> object.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">
|
||
|
The connection string contains any combination of <see langword="UserId" />, <see langword="Password" />, or <see langword="Integrated Security=true" />.
|
||
|
|
||
|
|
||
|
-or-
|
||
|
|
||
|
<paramref name="newSecurePassword" /> is greater than 128 characters.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
<paramref name="newSecurePassword" /> is not read only.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
<paramref name="newSecurePassword" /> is an empty string.</exception><exception cref="T:System.ArgumentNullException">One of the parameters (<paramref name="connectionString" />, <paramref name="credential" />, or <paramref name="newSecurePassword" />) is null.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnection.ChangePassword(System.String,System.String)">
|
||
|
<param name="connectionString">The connection string that contains enough information to connect to the server that you want. The connection string must contain the user ID and the current password.</param><param name="newPassword">The new password to set. This password must comply with any password security policy set on the server, including minimum length, requirements for specific characters, and so on.</param><summary>Changes the SQL Server password for the user indicated in the connection string to the supplied new password.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
When you are using SQL Server on Windows Server, developers can take advantage of functionality that lets the client application supply both the current and a new password in order to change the existing password. Applications can implement functionality such as prompting the user for a new password during initial login if the old one has expired, and this operation can be completed without administrator intervention.
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlConnection.ChangePassword%2A> method changes the SQL Server password for the user indicated in the supplied `connectionString` parameter to the value supplied in the `newPassword` parameter. If the connection string includes the option for integrated security (that is, "Integrated Security=True" or the equivalent), an exception is thrown.
|
||
|
|
||
|
To determine that the password has expired, calling the <xref:Microsoft.Data.SqlClient.SqlConnection.Open%2A> method raises a <xref:Microsoft.Data.SqlClient.SqlException>. In order to indicate that the password that is contained within the connection string must be reset, the <xref:Microsoft.Data.SqlClient.SqlException.Number%2A> property for the exception contains the status value 18487 or 18488. The first value (18487) indicates that the password has expired and the second (18488) indicates that the password must be reset before logging in.
|
||
|
|
||
|
This method opens its own connection to the server, requests the password change, and closes the connection as soon as it has completed. This connection is not retrieved from, nor returned to, the SQL Server connection pool.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following is a simple example of changing a password:
|
||
|
|
||
|
```csharp
|
||
|
class Program {
|
||
|
static void Main(string[] args) {
|
||
|
Microsoft.Data.SqlClient.SqlConnection.ChangePassword(
|
||
|
"Data Source=a_server;Initial Catalog=a_database;UID=user;PWD=old_password",
|
||
|
"new_password");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
```
|
||
|
|
||
|
```vb
|
||
|
Module Module1
|
||
|
Sub Main()
|
||
|
Microsoft.Data.SqlClient.SqlConnection.ChangePassword(
|
||
|
"Data Source=a_server;Initial Catalog=a_database;UID=user;PWD=old_password",
|
||
|
"new_password")
|
||
|
End Sub
|
||
|
End Module
|
||
|
|
||
|
```
|
||
|
|
||
|
The following console application demonstrates the issues involved in changing a user's password because the current password has expired.
|
||
|
|
||
|
[!code-csharp[SqlConnection_ConnectionString1#1](~/../sqlclient/doc/samples/SqlConnection_ConnectionString1.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentException">The connection string includes the option to use integrated security.
|
||
|
|
||
|
Or
|
||
|
|
||
|
The <paramref name="newPassword" /> exceeds 128 characters.</exception><exception cref="T:System.ArgumentNullException">Either the <paramref name="connectionString" /> or the <paramref name="newPassword" /> parameter is null.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnection.ClearAllPools">
|
||
|
<summary>Empties the connection pool.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
<xref:Microsoft.Data.SqlClient.SqlConnection.ClearAllPools%2A> resets (or empties) the connection pool. If there are connections in use at the time of the call, they are marked appropriately and will be discarded (instead of being returned to the pool) when <xref:Microsoft.Data.SqlClient.SqlConnection.Close%2A> is called on them.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnection.ClearPool(Microsoft.Data.SqlClient.SqlConnection)">
|
||
|
<param name="connection">The <see cref="T:Microsoft.Data.SqlClient.SqlConnection" /> to be cleared from the pool.</param><summary>Empties the connection pool associated with the specified connection.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
<xref:Microsoft.Data.SqlClient.SqlConnection.ClearPool%2A> clears the connection pool that is associated with the `connection`. If additional connections associated with `connection` are in use at the time of the call, they are marked appropriately and are discarded (instead of being returned to the pool) when <xref:Microsoft.Data.SqlClient.SqlConnection.Close%2A> is called on them.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnection.Close">
|
||
|
<summary>Closes the connection to the database. This is the preferred method of closing any open connection.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlConnection.Close%2A> method rolls back any pending transactions. It then releases the connection to the connection pool, or closes the connection if connection pooling is disabled.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> Pending transactions started using Transact-SQL or <xref:Microsoft.Data.SqlClient.SqlConnection.BeginTransaction%2A> are automatically rolled back when the connection is reset if connection pooling is enabled. If connection pooling is off, the transaction is rolled back after `SqlConnection.Close` is called. Transactions started through <xref:System.Transactions> are controlled through the `System.Transactions` infrastructure, and are not affected by `SqlConnection.Close`.
|
||
|
|
||
|
An application can call <xref:Microsoft.Data.SqlClient.SqlConnection.Close%2A> more than one time. No exception is generated.
|
||
|
|
||
|
If the <xref:Microsoft.Data.SqlClient.SqlConnection> goes out of scope, it won't be closed. Therefore, you must explicitly close the connection by calling `Close` or `Dispose`. `Close` and `Dispose` are functionally equivalent. If the connection pooling value `Pooling` is set to `true` or `yes`, the underlying connection is returned back to the connection pool. On the other hand, if `Pooling` is set to `false` or `no`, the underlying connection to the server is closed.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> Login and logout events will not be raised on the server when a connection is fetched from or returned to the connection pool, because the connection is not actually closed when it is returned to the connection pool. For more information, see [SQL Server Connection Pooling (ADO.NET)](/sql/connect/ado-net/sql-server-connection-pooling).
|
||
|
|
||
|
> [!CAUTION]
|
||
|
> Do not call `Close` or `Dispose` on a Connection, a DataReader, or any other managed object in the `Finalize` method of your class. In a finalizer, you should only release unmanaged resources that your class owns directly. If your class does not own any unmanaged resources, do not include a `Finalize` method in your class definition. For more information, see [Garbage Collection](/dotnet/standard/garbage-collection/).
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlConnection>, opens it, displays some of its properties. The connection is automatically closed at the end of the `using` block.
|
||
|
|
||
|
[!code-csharp[SqlConnection_Open Example#1](~/../sqlclient/doc/samples/SqlConnection_Open.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:Microsoft.Data.SqlClient.SqlException">The connection-level error that occurred while opening the connection.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnection.CreateCommand">
|
||
|
<summary>Creates and returns a <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> object associated with the <see cref="T:Microsoft.Data.SqlClient.SqlConnection" />.</summary><returns>A <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> object.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Examples
|
||
|
[!code-csharp[SqlConnection_CreateCommand#1](~/../sqlclient/doc/samples/SqlConnection_CreateCommand.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnection.CreateDbCommand">
|
||
|
<summary>To be added.</summary><returns>To be added.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnection.GetSchema">
|
||
|
<summary>Returns schema information for the data source of this <see cref="T:Microsoft.Data.SqlClient.SqlConnection" />. For more information about scheme, see [SQL Server Schema Collections](/sql/connect/ado-net/sql-server-schema-collections).</summary><returns>A <see cref="T:System.Data.DataTable" /> that contains schema information.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnection.GetSchema(System.String)">
|
||
|
<param name="collectionName">Specifies the name of the schema to return.</param><summary>Returns schema information for the data source of this <see cref="T:Microsoft.Data.SqlClient.SqlConnection" /> using the specified string for the schema name.</summary><returns>A <see cref="T:System.Data.DataTable" /> that contains schema information.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
You may need the schema information of the database, tables or columns. This sample:
|
||
|
|
||
|
- Uses GetSchema to get schema information.
|
||
|
|
||
|
- Use schema restrictions to get the specified information.
|
||
|
|
||
|
- Gets schema information of the database, tables, and some columns.
|
||
|
|
||
|
Before you run the sample, you need to create the sample database, using the following Transact-SQL:
|
||
|
|
||
|
```
|
||
|
USE [master]
|
||
|
GO
|
||
|
|
||
|
CREATE DATABASE [MySchool]
|
||
|
|
||
|
GO
|
||
|
|
||
|
USE [MySchool]
|
||
|
GO
|
||
|
|
||
|
SET ANSI_NULLS ON
|
||
|
GO
|
||
|
SET QUOTED_IDENTIFIER ON
|
||
|
GO
|
||
|
CREATE TABLE [dbo].[Course]([CourseID] [nvarchar](10) NOT NULL,
|
||
|
[Year] [smallint] NOT NULL,
|
||
|
[Title] [nvarchar](100) NOT NULL,
|
||
|
[Credits] [int] NOT NULL,
|
||
|
[DepartmentID] [int] NOT NULL,
|
||
|
CONSTRAINT [PK_Course] PRIMARY KEY CLUSTERED
|
||
|
(
|
||
|
[CourseID] ASC,
|
||
|
[Year] ASC
|
||
|
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]) ON [PRIMARY]
|
||
|
|
||
|
GO
|
||
|
|
||
|
SET ANSI_NULLS ON
|
||
|
GO
|
||
|
SET QUOTED_IDENTIFIER ON
|
||
|
GO
|
||
|
CREATE TABLE [dbo].[Department]([DepartmentID] [int] IDENTITY(1,1) NOT NULL,
|
||
|
[Name] [nvarchar](50) NOT NULL,
|
||
|
[Budget] [money] NOT NULL,
|
||
|
[StartDate] [datetime] NOT NULL,
|
||
|
[Administrator] [int] NULL,
|
||
|
CONSTRAINT [PK_Department] PRIMARY KEY CLUSTERED
|
||
|
(
|
||
|
[DepartmentID] ASC
|
||
|
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]) ON [PRIMARY]
|
||
|
|
||
|
GO
|
||
|
|
||
|
INSERT [dbo].[Course] ([CourseID], [Year], [Title], [Credits], [DepartmentID]) VALUES (N'C1045', 2012, N'Calculus', 4, 7)
|
||
|
INSERT [dbo].[Course] ([CourseID], [Year], [Title], [Credits], [DepartmentID]) VALUES (N'C1061', 2012, N'Physics', 4, 1)
|
||
|
INSERT [dbo].[Course] ([CourseID], [Year], [Title], [Credits], [DepartmentID]) VALUES (N'C2021', 2012, N'Composition', 3, 2)
|
||
|
INSERT [dbo].[Course] ([CourseID], [Year], [Title], [Credits], [DepartmentID]) VALUES (N'C2042', 2012, N'Literature', 4, 2)
|
||
|
|
||
|
SET IDENTITY_INSERT [dbo].[Department] ON
|
||
|
|
||
|
INSERT [dbo].[Department] ([DepartmentID], [Name], [Budget], [StartDate], [Administrator]) VALUES (1, N'Engineering', 350000.0000, CAST(0x0000999C00000000 AS DateTime), 2)
|
||
|
INSERT [dbo].[Department] ([DepartmentID], [Name], [Budget], [StartDate], [Administrator]) VALUES (2, N'English', 120000.0000, CAST(0x0000999C00000000 AS DateTime), 6)
|
||
|
INSERT [dbo].[Department] ([DepartmentID], [Name], [Budget], [StartDate], [Administrator]) VALUES (4, N'Economics', 200000.0000, CAST(0x0000999C00000000 AS DateTime), 4)
|
||
|
INSERT [dbo].[Department] ([DepartmentID], [Name], [Budget], [StartDate], [Administrator]) VALUES (7, N'Mathematics', 250024.0000, CAST(0x0000999C00000000 AS DateTime), 3)
|
||
|
SET IDENTITY_INSERT [dbo].[Department] OFF
|
||
|
|
||
|
ALTER TABLE [dbo].[Course] WITH CHECK ADD CONSTRAINT [FK_Course_Department] FOREIGN KEY([DepartmentID])
|
||
|
REFERENCES [dbo].[Department] ([DepartmentID])
|
||
|
GO
|
||
|
ALTER TABLE [dbo].[Course] CHECK CONSTRAINT [FK_Course_Department]
|
||
|
GO
|
||
|
```
|
||
|
|
||
|
[How to Get Schema Information from Database](https://code.msdn.microsoft.com/How-to-Get-Schema-b66d62e2) has C# and Visual Basic versions of this code sample in a Visual Studio project.
|
||
|
|
||
|
[!code-csharp[SqlConnection.GetSchema#1](~/../sqlclient/doc/samples/SqlConnection_GetSchema.cs#1)]
|
||
|
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="collectionName" /> is specified as null.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnection.GetSchema(System.String,System.String[])">
|
||
|
<param name="collectionName">Specifies the name of the schema to return.</param><param name="restrictionValues">A set of restriction values for the requested schema.</param><summary>Returns schema information for the data source of this <see cref="T:Microsoft.Data.SqlClient.SqlConnection" /> using the specified string for the schema name and the specified string array for the restriction values.</summary><returns>A <see cref="T:System.Data.DataTable" /> that contains schema information.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The `restrictionValues` parameter can supply *n* depth of values, which are specified by the restrictions collection for a specific collection. In order to set values on a given restriction, and not set the values of other restrictions, you need to set the preceding restrictions to `null` and then put the appropriate value in for the restriction that you would like to specify a value for.
|
||
|
|
||
|
An example of this is the "Tables" collection. If the "Tables" collection has three restrictions--database, owner, and table name--and you want to get back only the tables associated with the owner "Carl", you need to pass in the following values: null, "Carl". If a restriction value is not passed in, the default values are used for that restriction. This is the same mapping as passing in `null`, which is different from passing in an empty string for the parameter value. In that case, the empty string ("") is considered to be the value for the specified parameter.
|
||
|
|
||
|
For a code sample demonstrating <xref:Microsoft.Data.SqlClient.SqlConnection.GetSchema%2A>, see <xref:Microsoft.Data.SqlClient.SqlConnection.GetSchema%2A>.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="collectionName" /> is specified as null.</exception><altmember cref="M:Microsoft.Data.SqlClient.SqlConnection.GetSchema" />
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnection.Open">
|
||
|
<summary>Opens a database connection with the property settings specified by the <see cref="P:Microsoft.Data.SqlClient.SqlConnection.ConnectionString" />.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlConnection> draws an open connection from the connection pool if one is available. Otherwise, it establishes a new connection to an instance of SQL Server.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> If the <xref:Microsoft.Data.SqlClient.SqlConnection> goes out of scope, it is not closed. Therefore, you must explicitly close the connection by calling <xref:Microsoft.Data.SqlClient.SqlConnection.Close%2A>.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> If you specify a port number other than 1433 when you are trying to connect to an instance of SQL Server and using a protocol other than TCP/IP, the <xref:Microsoft.Data.SqlClient.SqlConnection.Open%2A> method fails. To specify a port number other than 1433, include "server=machinename,port number" in the connection string, and use the TCP/IP protocol.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> The .NET Framework Data Provider for SQL Server requires the Security permission with "Allows calls to unmanaged assemblies" enabled (<xref:System.Security.Permissions.SecurityPermission> with <xref:System.Security.Permissions.SecurityPermissionFlag> set to `UnmanagedCode`) to open a <xref:Microsoft.Data.SqlClient.SqlConnection> with SQL Debugging enabled.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlConnection>, opens it, and displays some of its properties. The connection is automatically closed at the end of the `using` block.
|
||
|
|
||
|
[!code-csharp[SqlConnection_Open Example#1](~/../sqlclient/doc/samples/SqlConnection_Open.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidOperationException">Cannot open a connection without specifying a data source or server.
|
||
|
|
||
|
or
|
||
|
|
||
|
The connection is already open.</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">A connection-level error occurred while opening the connection. If the <see cref="P:Microsoft.Data.SqlClient.SqlException.Number" /> property contains the value 18487 or 18488, this indicates that the specified password has expired or must be reset. See the <see cref="M:Microsoft.Data.SqlClient.SqlConnection.ChangePassword(System.String,System.String)" /> method for more information.
|
||
|
|
||
|
The <see langword="<system.data.localdb>" /> tag in the app.config file has invalid or unknown elements.</exception><exception cref="T:System.Configuration.ConfigurationErrorsException">There are two entries with the same name in the <see langword="<localdbinstances>" /> section.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnection.Open(Microsoft.Data.SqlClient.SqlConnectionOverrides)">
|
||
|
<param name="overrides">Options to override default connection open behavior.</param><summary>
|
||
|
Opens a database connection with the property settings specified by the <see cref="P:Microsoft.Data.SqlClient.SqlConnection.ConnectionString" />.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown">
|
||
|
<![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlConnection> draws an open connection from the connection pool if one is available. Otherwise, it establishes a new connection to an instance of SQL Server. If overrides are specified, the first open attempt will apply the specified overrides to the open action.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> If the <xref:Microsoft.Data.SqlClient.SqlConnection> goes out of scope, it is not closed. Therefore, you must explicitly close the connection by calling <xref:Microsoft.Data.SqlClient.SqlConnection.Close%2A>.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> If you specify a port number other than 1433 when you are trying to connect to an instance of SQL Server and using a protocol other than TCP/IP, the <xref:Microsoft.Data.SqlClient.SqlConnection.Open%2A> method fails. To specify a port number other than 1433, include "server=machinename,port number" in the connection string, and use the TCP/IP protocol.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> The .NET Framework Data Provider for SQL Server requires the Security permission with "Allows calls to unmanaged assemblies" enabled (<xref:System.Security.Permissions.SecurityPermission> with <xref:System.Security.Permissions.SecurityPermissionFlag> set to `UnmanagedCode`) to open a <xref:Microsoft.Data.SqlClient.SqlConnection> with SQL Debugging enabled.
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlConnection>, opens it, and displays some of its properties. The connection is automatically closed at the end of the `using` block.
|
||
|
|
||
|
[!code-csharp[SqlConnection_Open Example#1](~/../sqlclient/doc/samples/SqlConnection_Open.cs#1)]
|
||
|
|
||
|
]]>
|
||
|
</format>
|
||
|
</remarks><exception cref="T:System.InvalidOperationException">Cannot open a connection without specifying a data source or server.
|
||
|
|
||
|
or
|
||
|
|
||
|
The connection is already open.
|
||
|
</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">A connection-level error occurred while opening the connection. If the <see cref="P:Microsoft.Data.SqlClient.SqlException.Number" /> property contains the value 18487 or 18488, this indicates that the specified password has expired or must be reset. See the <see cref="M:Microsoft.Data.SqlClient.SqlConnection.ChangePassword(System.String,System.String)" /> method for more information.
|
||
|
|
||
|
The <see langword="<system.data.localdb>" /> tag in the app.config file has invalid or unknown elements.</exception><exception cref="T:System.Configuration.ConfigurationErrorsException">There are two entries with the same name in the <see langword="<localdbinstances>" /> section.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnection.OpenAsync(System.Threading.CancellationToken)">
|
||
|
<param name="cancellationToken">The cancellation instruction.</param><summary>An asynchronous version of <see cref="M:Microsoft.Data.SqlClient.SqlConnection.Open" />, which opens a database connection with the property settings specified by the <see cref="P:Microsoft.Data.SqlClient.SqlConnection.ConnectionString" />. The cancellation token can be used to request that the operation be abandoned before the connection timeout elapses. Exceptions will be propagated via the returned Task. If the connection timeout time elapses without successfully connecting, the returned Task will be marked as faulted with an Exception. The implementation returns a Task without blocking the calling thread for both pooled and non-pooled connections.</summary><returns>A task representing the asynchronous operation.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
After calling <xref:Microsoft.Data.SqlClient.SqlConnection.OpenAsync%2A>, <xref:Microsoft.Data.SqlClient.SqlConnection.State%2A> must return <xref:System.Data.ConnectionState.Connecting> until the returned <xref:System.Threading.Tasks.Task> is completed. Then, if the connection was successful, <xref:Microsoft.Data.SqlClient.SqlConnection.State%2A> must return <xref:System.Data.ConnectionState.Open>. If the connection fails, <xref:Microsoft.Data.SqlClient.SqlConnection.State%2A> must return <xref:System.Data.ConnectionState.Closed>.
|
||
|
|
||
|
A call to <xref:Microsoft.Data.SqlClient.SqlConnection.Close%2A> will attempt to cancel or close the corresponding <xref:Microsoft.Data.SqlClient.SqlConnection.OpenAsync%2A> call.
|
||
|
|
||
|
For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see [Asynchronous Programming](/sql/connect/ado-net/asynchronous-programming).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidOperationException">Calling <see cref="M:Microsoft.Data.SqlClient.SqlConnection.OpenAsync(System.Threading.CancellationToken)" /> more than once for the same instance before task completion.
|
||
|
|
||
|
A connection was not available from the connection pool before the connection time out elapsed.</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">Any error returned by SQL Server that occurred while opening the connection.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnection.ResetStatistics">
|
||
|
<summary>If statistics gathering is enabled, all values are reset to zero.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
If statistics gathering is not enabled and this method is called, no error is thrown.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnection.RetrieveStatistics">
|
||
|
<summary>Returns a name value pair collection of statistics at the point in time the method is called.</summary><returns>Returns a reference of type <see cref="T:System.Collections.IDictionary" /> of <see cref="T:System.Collections.DictionaryEntry" /> items.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
When this method is called, the values retrieved are those at the current point in time. If you continue using the connection, the values are incorrect. You need to re-execute the method to obtain the most current values.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnection.RetrieveInternalInfo">
|
||
|
<summary>Returns a name value pair collection of internal properties at the point in time the method is called.</summary><returns>Returns a reference of type <see cref="T:System.Collections.Generic.IDictionary`2" /> of (string, object) items.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
When this method is called, the values retrieved are those at the current point in time. If you continue using the connection, the values are incorrect. You need to re-execute the method to obtain the most current values.
|
||
|
|
||
|
|Supported internal properties|Type|Information provided|Return value|
|
||
|
|-----------------------------|---------|----------------------------|------------|
|
||
|
|`SQLDNSCachingSupportedState`|string|To indicate the IsSupported flag sent by the server for DNS Caching|"true", "false", "innerConnection is null!"|
|
||
|
|`SQLDNSCachingSupportedStateBeforeRedirect`|string|To indicate the IsSupported flag sent by the server for DNS Caching before redirection.|"true", "false", "innerConnection is null!"|
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnection.RetryLogicProvider">
|
||
|
<summary> Gets or sets a value that specifies the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlRetryLogicBaseProvider" />
|
||
|
object bound to this command.
|
||
|
</summary><value>
|
||
|
When set to null (default), the default non-retriable provider will be applied.
|
||
|
</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
You must set the value for this property before opening the connection to take effect.
|
||
|
|
||
|
To apply the retry logic, do the following steps before opening the connection:
|
||
|
1. Define the configuration parameters by using <xref:Microsoft.Data.SqlClient.SqlRetryLogicOption> type.
|
||
|
2. Create a <xref:Microsoft.Data.SqlClient.SqlRetryLogicBaseProvider> by using one of the following static methods of the <xref:Microsoft.Data.SqlClient.SqlConfigurableRetryFactory> class:
|
||
|
- <xref:Microsoft.Data.SqlClient.SqlConfigurableRetryFactory.CreateFixedRetryProvider%2A>
|
||
|
- <xref:Microsoft.Data.SqlClient.SqlConfigurableRetryFactory.CreateIncrementalRetryProvider%2A>
|
||
|
- <xref:Microsoft.Data.SqlClient.SqlConfigurableRetryFactory.CreateExponentialRetryProvider%2A>
|
||
|
- <xref:Microsoft.Data.SqlClient.SqlConfigurableRetryFactory.CreateNoneRetryProvider%2A>
|
||
|
3. Assign the <xref:Microsoft.Data.SqlClient.SqlRetryLogicBaseProvider> object to the `RetryLogicProvider` property.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> Detecting retriable exceptions is a vital part of the retry pattern. Before applying retry logic, it is important to investigate exceptions and choose a retry provider that best fits your scenario. First, log your exceptions and find transient faults.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> The connection **timeout** restarts for each execution of a connection open. There is no timing overlap between these two actions.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> The default retry logic provider is not enabled unless it is configured in an application configuration file. For more information, see [Configurable retry logic and configuration file](/sql/connect/ado-net/configurable-retry-logic-config-file-sqlclient).
|
||
|
|
||
|
## Example
|
||
|
The following sample tries to open a connection to an invalid database to simulate a condition that the database service is temporarily unavailable . You should manually create the database while the <xref:Microsoft.Data.SqlClient.SqlConnection> tries to establish the connection.
|
||
|
|
||
|
[!code-csharp[SqlConfigurableRetryLogic_OpenConnection#1](~/../sqlclient/doc/samples/SqlConfigurableRetryLogic_OpenConnection.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnection.Dispose(System.Boolean)">
|
||
|
<param name="disposing">To be added.</param><summary>To be added.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnection.CanCreateBatch">
|
||
|
<summary>Gets a value that indicates whether this <see cref="T:Microsoft.Data.SqlClient.SqlConnection" /> instance supports the <see cref="T:System.Data.Common.DbBatch" /> class.</summary><value>
|
||
|
<see langword="true" /> if this instance supports the <see cref="T:System.Data.Common.DbBatch" /> class; otherwise, <see langword="false" />. The default is <see langword="true" />.
|
||
|
</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
|
||
|
ADO.net SQL provider implemented <xref:System.Data.Common.DbBatch> and overrides `CanCreateBatch` property to return `true`.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnection.CreateDbBatch">
|
||
|
<summary>Returns a new instance of the <see cref="T:Mictosoft.Data.SqlClient.SqlBatch" /> class that implements the <see cref="T:System.Data.Common.DbBatch" /> class.</summary><returns>A new instance of <see cref="T:Mictosoft.Data.SqlClient.SqlBatch" />.</returns>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlConnectionColumnEncryptionSetting">
|
||
|
<summary>Note that these settings cannot be used to bypass encryption and gain access to plaintext data. For details, see <see href="https://docs.microsoft.com/sql/relational-databases/security/encryption/always-encrypted-database-engine">Always Encrypted (Database Engine)</see>.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlConnectionColumnEncryptionSetting.Disabled">
|
||
|
<summary>Specifies the connection does not use Always Encrypted. Should be used if no queries sent over the connection access encrypted columns.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlConnectionColumnEncryptionSetting.Enabled">
|
||
|
<summary>Enables Always Encrypted functionality for the connection. Query parameters that correspond to encrypted columns will be transparently encrypted and query results from encrypted columns will be transparently decrypted.</summary>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlConnectionOverrides">
|
||
|
<summary>
|
||
|
Specifies a value for Overrides.
|
||
|
</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlConnectionOverrides.None">
|
||
|
<summary>No overrides.</summary><value>0</value>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlConnectionOverrides.OpenWithoutRetry">
|
||
|
<summary>Disable transient fault handling during the initial SqlConnection Open attempt.</summary><value>1</value>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlConnectionStringBuilder">
|
||
|
<summary>Provides a simple way to create and manage the contents of connection strings used by the <see cref="T:Microsoft.Data.SqlClient.SqlConnection" /> class.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The connection string builder lets developers programmatically create syntactically correct connection strings, and parse and rebuild existing connection strings, using properties and methods of the class. The connection string builder provides strongly typed properties corresponding to the known key/value pairs allowed by SQL Server. Developers needing to create connection strings as part of applications can use the <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder> class to build and modify connection strings. The class also makes it easy to manage connection strings stored in an application configuration file.
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder> performs checks for valid key/value pairs. Therefore, you cannot use this class to create invalid connection strings; trying to add invalid pairs will throw an exception. The class maintains a fixed collection of synonyms and can translate from a synonym to the corresponding well-known key name.
|
||
|
|
||
|
For example, when you use the **Item** property to retrieve a value, you can specify a string that contains any synonym for the key you need. For example, you can specify "Network Address", "addr", or any other acceptable synonym for this key within a connection string when you use any member that requires a string that contains the key name, such as the **Item** property or the <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.Remove%2A> method. See the <xref:Microsoft.Data.SqlClient.SqlConnection.ConnectionString%2A> property for a full list of acceptable synonyms.
|
||
|
|
||
|
The **Item** property handles tries to insert malicious entries. For example, the following code, using the default Item property (the indexer, in C#) correctly escapes the nested key/value pair:
|
||
|
|
||
|
```vb
|
||
|
Dim builder As New Microsoft.Data.SqlClient.SqlConnectionStringBuilder
|
||
|
builder("Data Source") = "(local)"
|
||
|
builder("Integrated Security") = True
|
||
|
builder("Initial Catalog") = "AdventureWorks;NewValue=Bad"
|
||
|
Console.WriteLine(builder.ConnectionString)
|
||
|
```
|
||
|
|
||
|
```csharp
|
||
|
Microsoft.Data.SqlClient.SqlConnectionStringBuilder builder =
|
||
|
new Microsoft.Data.SqlClient.SqlConnectionStringBuilder();
|
||
|
builder["Data Source"] = "(local)";
|
||
|
builder["Integrated Security"] = true;
|
||
|
builder["Initial Catalog"] = "AdventureWorks;NewValue=Bad";
|
||
|
Console.WriteLine(builder.ConnectionString);
|
||
|
|
||
|
```
|
||
|
|
||
|
The result is the following connection string that handles the invalid value in a safe manner:
|
||
|
|
||
|
```
|
||
|
Source=(local);Initial Catalog="AdventureWorks;NewValue=Bad";
|
||
|
Integrated Security=True
|
||
|
```
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following console application builds connection strings for a SQL Server database. The code uses a <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder> class to create the connection string, and then passes the <xref:System.Data.Common.DbConnectionStringBuilder.ConnectionString%2A> property of the <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder> instance to the constructor of the connection class. The example also parses an existing connection string and demonstrates various ways of manipulating the connection string's contents.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> This example includes a password to demonstrate how <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder> works with connection strings. In your applications, we recommend that you use Windows Authentication. If you must use a password, do not include a hard-coded password in your application.
|
||
|
|
||
|
[!code-csharp[SqlConnectionStringBuilder#1](~/../sqlclient/doc/samples/SqlConnectionStringBuilder.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.#ctor">
|
||
|
<summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.SqlConnectionStringBuilder" /> class.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.#ctor(System.String)">
|
||
|
<param name="connectionString">The basis for the object's internal connection information. Parsed into name/value pairs. Invalid key names raise <see cref="T:System.Collections.Generic.KeyNotFoundException" />.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.SqlConnectionStringBuilder" /> class. The provided connection string provides the data for the instance's internal connection information.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder> class provides a fixed internal collection of key/value pairs. Even if you supply only a small subset of the possible connection string values in the constructor, the object always provides default values for each key/value pair. When the `ConnectionString` property of the object is retrieved, the string contains only key/value pairs in which the value is not the default value for the item.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example supplies a simple SQL Server connection string in the <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder> object's constructor, and then iterates through all the key/value pairs within the object. Note that the collection provides default values for each item. Also note that the <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder> class converts synonyms for the well-known keys so that they are consistent with the well-known names.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> This example includes a password to demonstrate how <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder> works with connection strings. In your applications, we recommend that you use Windows Authentication. If you must use a password, do not include a hard-coded password in your application.
|
||
|
|
||
|
[!code-csharp[SqlConnectionStringBuilder3#1](~/../sqlclient/doc/samples/SqlConnectionStringBuilder3.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.Collections.Generic.KeyNotFoundException">Invalid key name within the connection string.</exception><exception cref="T:System.FormatException">Invalid value within the connection string (specifically, when a Boolean or numeric value was expected but not supplied).</exception><exception cref="T:System.ArgumentException">The supplied <paramref name="connectionString" /> is not valid.</exception>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.ApplicationIntent">
|
||
|
<summary>Declares the application workload type when connecting to a database in an SQL Server Availability Group. You can set the value of this property with <see cref="T:Microsoft.Data.SqlClient.ApplicationIntent" />. For more information about SqlClient support for Always On Availability Groups, see [SqlClient Support for High Availability, Disaster Recovery](/sql/connect/ado-net/sql/sqlclient-support-high-availability-disaster-recovery).</summary><value>Returns the current value of the property.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This property corresponds to the "Application Intent" and "ApplicationIntent" keys within the connection string.
|
||
|
|
||
|
The default value is `ApplicationIntent.ReadWrite`.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><related type="Article" href="/sql/connect/ado-net/overview-sqlclient-driver">Overview of the SqlClient driver</related>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.ApplicationName">
|
||
|
<summary>Gets or sets the name of the application associated with the connection string.</summary><value>The name of the application. If no name has been supplied, "Framework Microsoft SqlClient Data Provider" when running on .NET Framework and "Core Microsoft SqlClient Data Provider" otherwise.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This property corresponds to the "Application Name" and "app" keys within the connection string.
|
||
|
|
||
|
An application name can be 128 characters or less.
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a new <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder> and assigns a connection string in the object's constructor. The code displays the parsed and recreated version of the connection string, and then modifies the <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.ApplicationName%2A> property of the object. Finally, the code displays the new connection string, including the new key/value pair.
|
||
|
|
||
|
[!code-csharp[SqlConnectionStringBuilder.ApplicationName#1](~/../sqlclient/doc/samples/SqlConnectionStringBuilder_ApplicationName.cs#1)]
|
||
|
|
||
|
The sample displays the following text in the console window:
|
||
|
|
||
|
```
|
||
|
Original: Data Source=(local);Initial Catalog=AdventureWorks;Integrated Security=True
|
||
|
ApplicationName="Core Microsoft SqlClient Data Provider"
|
||
|
Modified: Data Source=(local);Initial Catalog=AdventureWorks;Integrated Security=True;Application Name="My Application"
|
||
|
```
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">To set the value to null, use <see cref="F:System.DBNull.Value" />.</exception>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.AttachDBFilename">
|
||
|
<summary>Gets or sets a string that contains the name of the primary data file. This includes the full path name of an attachable database.</summary><value>The value of the <see langword="AttachDBFilename" /> property, or <see langword="String.Empty" /> if no value has been supplied.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This property corresponds to the "AttachDBFilename", "extended properties", and "initial file name" keys within the connection string.
|
||
|
|
||
|
`AttachDBFilename` is only supported for primary data files with an .mdf extension.
|
||
|
|
||
|
If the value of the AttachDBFileName key is specified in the connection string, the database is attached and becomes the default database for the connection.
|
||
|
|
||
|
If this key is not specified and if the database was previously attached, the database will not be reattached. The previously attached database will be used as the default database for the connection.
|
||
|
|
||
|
If this key is specified together with the AttachDBFileName key, the value of this key will be used as the alias. However, if the name is already used in another attached database, the connection will fail.
|
||
|
|
||
|
The path may be absolute or relative by using the DataDirectory substitution string. If DataDirectory is used, the database file must exist within a subdirectory of the directory pointed to by the substitution string. **Note:** Remote server, HTTP, and UNC path names are not supported.
|
||
|
|
||
|
The database name must be specified with the keyword 'database' (or one of its aliases) as in the following:
|
||
|
|
||
|
`"AttachDbFileName=|DataDirectory|\data\YourDB.mdf;integrated security=true;database=YourDatabase"`
|
||
|
|
||
|
An error will be generated if a log file exists in the same directory as the data file and the 'database' keyword is used when attaching the primary data file. In this case, remove the log file. Once the database is attached, a new log file will be automatically generated based on the physical path.
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a new <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder> instance, and sets the `AttachDBFilename` property in order to specify the name of an attached data file.
|
||
|
|
||
|
[!code-csharp[DataWorks SqlConnectionStringBuilder_AttachDBFilename#1](~/../sqlclient/doc/samples/SqlConnectionStringBuilder_AttachDBFilename.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">To set the value to null, use <see cref="F:System.DBNull.Value" />.</exception><related type="Article" href="https://msdn.microsoft.com/library/745c5f95-2f02-4674-b378-6d51a7ec2490">Working with Connection Strings</related><related type="Article" href="/sql/connect/ado-net/overview-sqlclient-driver">Overview of the SqlClient driver</related>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.Authentication">
|
||
|
<summary>Gets or sets the authentication method used for [Connecting to SQL Database By Using Azure Active Directory Authentication](https://azure.microsoft.com/documentation/articles/sql-database-aad-authentication/#7-connect-to-your-database-by-using-azure-active-directory-identities).</summary><value>The authentication method of the connection string.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
|
||
|
For more information, see [Using Azure Active Directory authentication with SqlClient](/sql/connect/ado-net/sql/azure-active-directory-authentication).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.ColumnEncryptionSetting">
|
||
|
<summary>Gets or sets the column encryption settings for the connection string builder.</summary><value>The column encryption settings for the connection string builder.This property enables or disables [Always Encrypted](/sql/relational-databases/security/encryption/always-encrypted-database-engine) functionality for the connection.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.CommandTimeout">
|
||
|
<summary>
|
||
|
The default wait time (in seconds) before terminating the attempt to execute a command and generating an error. The default is 30 seconds.
|
||
|
</summary><value>
|
||
|
The time in seconds to wait for the command to execute. The default is 30 seconds.
|
||
|
</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This property corresponds to the "Command Timeout" key within the <xref:Microsoft.Data.SqlClient.SqlConnection> connection string.
|
||
|
|
||
|
Valid values are greater than or equal to 0 and less than or equal to 2147483647.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentException">The value set is less than 0.</exception>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.ConnectRetryCount">
|
||
|
<summary>The number of reconnections attempted after identifying that there was an idle connection failure. This must be an integer between 0 and 255. The default value for non Azure endpoints is 1. For Azure SQL endpoints, the default is 2. Starting in version 5.x, for Azure SQL serverless or on demand endpoints, the default is 5 to improve connection success for connections to an idle or paused instance. Set to 0 to disable reconnecting on idle connection failures. An <see cref="T:System.ArgumentException" /> will be thrown if set to a value outside of the allowed range.</summary><value>The number of reconnections attempted after identifying that there was an idle connection failure.</value><remarks>
|
||
|
<format type="text/markdown">
|
||
|
<![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This property corresponds to the "Connect Retry Count" key within the <xref:Microsoft.Data.SqlClient.SqlConnection> connection string.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> Since version 5.x the default value for none Azure endpoints is 1 and for Azure SQL and Azure Synapse has increased to 2 and 5 to imporve the recovery against on high demand Azure endpoints. It should be detected first, and Synapse could be detected as a regular Azure SQL DB endpoint.
|
||
|
|
||
|
]]>
|
||
|
</format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.ConnectRetryInterval">
|
||
|
<summary>Amount of time (in seconds) between each reconnection attempt after identifying that there was an idle connection failure. This must be an integer between 1 and 60. The default is 10 seconds.</summary><value>Amount of time (in seconds) between each reconnection attempt after identifying that there was an idle connection failure.</value><exception cref="T:System.ArgumentException">Value is outside of the allowed range.</exception><remarks>
|
||
|
<format type="text/markdown">
|
||
|
<![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This property corresponds to the "Connect Retry Interval" key within the <xref:Microsoft.Data.SqlClient.SqlConnection> connection string.
|
||
|
|
||
|
This value is applied after the first reconnection attempt. When a broken connection is detected, the client immediately attempts to reconnect; this is the first reconnection attempt and only occurs if `ConnectRetryCount` is greater than 0. If the first reconnection attempt fails and `ConnectRetryCount` is greater than 1, the client waits `ConnectRetryInterval` to try the second and subsequent reconnection attempts.
|
||
|
|
||
|
]]>
|
||
|
</format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.ConnectTimeout">
|
||
|
<summary>Gets or sets the length of time (in seconds) to wait for a connection to the server before terminating the attempt and generating an error.</summary><value>The value of the <see cref="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.ConnectTimeout" /> property, or 15 seconds if no value has been supplied.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This property corresponds to the "Connect Timeout", "connection timeout", and "timeout" keys within the connection string.
|
||
|
|
||
|
When opening a connection to a Azure SQL Database, set the connection timeout to 30 seconds.
|
||
|
|
||
|
Valid values are greater than or equal to 0 and less than or equal to 2147483647.
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example first displays the contents of a connection string that does not specify the "Connect Timeout" value, sets the <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.ConnectTimeout%2A> property, and then displays the new connection string.
|
||
|
|
||
|
[!code-csharp[SqlConnectionStringBuilder_ConnectTimeout#1](~/../sqlclient/doc/samples/SqlConnectionStringBuilder_ConnectTimeout.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.CurrentLanguage">
|
||
|
<summary>Gets or sets the language used for database server warning or error messages..</summary><value>The value of the <see cref="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.CurrentLanguage" /> property, or <see langword="String.Empty" /> if no value has been supplied.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This property corresponds to the "Current Language" and "language" keys within the connection string.
|
||
|
|
||
|
The language name can be 128 characters or less.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">To set the value to null, use <see cref="F:System.DBNull.Value" />.</exception>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.DataSource">
|
||
|
<summary>Gets or sets the name or network address of the instance of SQL Server to connect to.</summary><value>The value of the <see cref="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.DataSource" /> property, or <see langword="String.Empty" /> if none has been supplied.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This property corresponds to the "Data Source", "server", "address", "addr", and "network address" keys within the connection string. Regardless of which of these values has been supplied within the supplied connection string, the connection string created by the `SqlConnectionStringBuilder` will use the well-known "Data Source" key.
|
||
|
|
||
|
The port number can be specified after the server name: `server=tcp:servername, portnumber`.
|
||
|
|
||
|
When specifying a local instance, always use (local). To force a protocol, add one of the following prefixes:`np:(local), tcp:(local), lpc:(local)`.
|
||
|
|
||
|
You can also connect to a LocalDB database as follows: `server=(localdb)\\myInstance`. For more information about LocalDB, see [SqlClient Support for LocalDB](/sql/connect/ado-net/sql/sqlclient-support-localdb).
|
||
|
**Data Source** must use the TCP format or the Named Pipes format. TCP format is as follows:
|
||
|
|
||
|
- tcp:\<host name>\\<instance name\>
|
||
|
- tcp:\<host name>,\<TCP/IP port number>
|
||
|
|
||
|
The TCP format must start with the prefix "tcp:" and is followed by the database instance, as specified by a host name and an instance name. This format is not applicable when connecting to Azure SQL Database. TCP is automatically selected for connections to Azure SQL Database when no protocol is specified.
|
||
|
|
||
|
The host name MUST be specified in one of the following ways:
|
||
|
- NetBIOSName
|
||
|
- IPv4Address
|
||
|
- IPv6Address
|
||
|
|
||
|
The instance name is used to resolve to a particular TCP/IP port number on which a database instance is hosted. Alternatively, specifying a TCP/IP port number directly is also allowed. If both instance name and port number are not present, the default database instance is used.
|
||
|
|
||
|
The Named Pipes format is as follows:
|
||
|
- np:\\\\<host name\>\pipe\\<pipe name\>
|
||
|
|
||
|
The Named Pipes format MUST start with the prefix "np:" and is followed by a named pipe name.
|
||
|
|
||
|
The host name MUST be specified in one of the following ways:
|
||
|
|
||
|
- NetBIOSName
|
||
|
- IPv4Address
|
||
|
- IPv6Address
|
||
|
|
||
|
The pipe name is used to identify the database instance to which the .NET application will connect.
|
||
|
|
||
|
If the value of the **Network** key is specified, the prefixes "tcp:" and "np:" should not be specified. **Note:** You can force the use of TCP instead of shared memory, either by prefixing **tcp:** to the server name in the connection string, or by using **localhost**.
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example demonstrates that the <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder> class converts synonyms for the "Data Source" connection string key into the well-known key:
|
||
|
|
||
|
[!code-csharp[SqlConnectionStringBuilder_DataSource#1](~/../sqlclient/doc/samples/SqlConnectionStringBuilder_DataSource.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">To set the value to null, use <see cref="F:System.DBNull.Value" />.</exception>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.AttestationProtocol">
|
||
|
<summary>Gets or sets the value of Attestation Protocol.</summary><value>The attestation protocol.</value><remarks>
|
||
|
<format type="text/markdown">
|
||
|
<![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
|
||
|
When no value is specified, secure enclaves are disabled on the connection.
|
||
|
|
||
|
]]>
|
||
|
</format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.EnclaveAttestationUrl">
|
||
|
<summary>Gets or sets the enclave attestation URL to be used with enclave based Always Encrypted.</summary><value>The enclave attestation URL.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.IPAddressPreference">
|
||
|
<summary>Gets or sets the IP address family preference when establishing TCP connections.</summary><returns>Returns the IP address preference.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
If `Transparent Network IP Resolution` (in .NET Framework) or `Multi Subnet Failover` is set to true, this setting has no effect.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.Encrypt">
|
||
|
<summary>Gets or sets a <see cref="T:Microsoft.Data.SqlClient.SqlConnectionEncryptOption" /> value since version 5.0 or a <see cref="T:System.Boolean" /> value for the earlier versions that indicates whether TLS encryption is required for all data sent between the client and server.</summary><value>The value of the <see cref="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.Encrypt" /> property.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This property corresponds to the "Encrypt" key within the connection string.
|
||
|
|
||
|
When `TrustServerCertificate` is false and `Encrypt` is <xref:Microsoft.Data.SqlClient.SqlConnectionEncryptOption.Mandatory%2A>, <xref:Microsoft.Data.SqlClient.SqlConnectionEncryptOption.Strict%2A> or `true`, the server name (or IP address) in a server's TLS certificate must exactly match the server name (or IP address) specified in the connection string. Otherwise, the connection attempt will fail. For information about support for certificates whose subject starts with a wildcard character (*), see [Enable encrypted connections to the Database Engine](/sql/database-engine/configure-windows/enable-encrypted-connections-to-the-database-engine#certificate-requirements).
|
||
|
|
||
|
> [!NOTE]
|
||
|
> Starting from **version 4.0**, the default value of the property `Encrypt` is set to `true` while it is `false` for earlier versions.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> Starting from **version 5.0**, the data type is updated to <xref:Microsoft.Data.SqlClient.SqlConnectionEncryptOption>, and the default value of the `Encrypt` property is set to <xref:Microsoft.Data.SqlClient.SqlConnectionEncryptOption.Mandatory%2A>.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><related type="Article" href="https://msdn.microsoft.com/library/745c5f95-2f02-4674-b378-6d51a7ec2490">Working with Connection Strings</related><related type="Article" href="/sql/connect/ado-net/overview-sqlclient-driver">Overview of the SqlClient driver</related>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.HostNameInCertificate">
|
||
|
<summary>Gets or sets the host name to use when validating the server certificate for the connection. When not specified, the server name from the `Data Source` is used for certificate validation. (Only available in v5.0+)</summary><value>
|
||
|
The value of the <see cref="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.HostNameInCertificate" /> property, or <see langword="String.Empty" /> if none has been supplied.
|
||
|
</value><remarks>
|
||
|
<format type="text/markdown">
|
||
|
<![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This property corresponds to the "HostNameInCertificiate" and "Host Name in Certificiate" keys within the connection string.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> This property only applies when using `Encrypt` in <xref:Microsoft.Data.SqlClient.SqlConnectionEncryptOption.Mandatory%2A> or <xref:Microsoft.Data.SqlClient.SqlConnectionEncryptOption.Strict%2A> mode, otherwise it is ignored.
|
||
|
|
||
|
]]>
|
||
|
</format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.ServerCertificate">
|
||
|
<summary>Gets or sets the path to a certificate file to match against the SQL Server TLS/SSL certificate for the connection. The accepted certificate formats are PEM, DER, and CER. If specified, the SQL Server certificate is checked by verifying if the `ServerCertificate` provided is an exact match. (Only available in v5.1+)</summary><value>
|
||
|
The value of the <see cref="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.ServerCertificate" /> property, or <see langword="String.Empty" /> if none has been supplied.
|
||
|
</value><remarks>
|
||
|
<format type="text/markdown">
|
||
|
<![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This property corresponds to the "ServerCertificate" and "Server Certificate" keys within the connection string.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> This property only applies when using `Encrypt` in <xref:Microsoft.Data.SqlClient.SqlConnectionEncryptOption.Mandatory%2A> or <xref:Microsoft.Data.SqlClient.SqlConnectionEncryptOption.Strict%2A> mode, otherwise it is ignored.
|
||
|
|
||
|
]]>
|
||
|
</format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.Enlist">
|
||
|
<summary>Gets or sets a Boolean value that indicates whether the SQL Server connection pooler automatically enlists the connection in the creation thread's current transaction context.</summary><value>The value of the <see cref="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.Enlist" /> property, or <see langword="true" /> if none has been supplied.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This property corresponds to the "Enlist" key within the connection string.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.FailoverPartner">
|
||
|
<summary>Gets or sets the name or address of the partner server to connect to if the primary server is down.</summary><value>The value of the <see cref="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.FailoverPartner" /> property, or <see langword="String.Empty" /> if none has been supplied.</value><exception cref="T:System.ArgumentNullException">To set the value to null, use <see cref="F:System.DBNull.Value" />.</exception><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
If the value of this key is "", then **Initial Catalog** must be present, and its value must not be "".
|
||
|
|
||
|
The server name can be 128 characters or less.
|
||
|
|
||
|
If you specify a failover partner but the failover partner server is not configured for database mirroring and the primary server (specified with the Server keyword) is not available, then the connection will fail.
|
||
|
|
||
|
If you specify a failover partner and the primary server is not configured for database mirroring, the connection to the primary server (specified with the Server keyword) will succeed if the primary server is available.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.FailoverPartnerSPN">
|
||
|
<summary>Gets or sets the service principal name (SPN) of the failover partner for the connection.</summary><value>
|
||
|
The value of the <see cref="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.FailoverPartnerSPN" /> property, or <see langword="String.Empty" /> if none has been supplied.
|
||
|
</value><remarks>
|
||
|
<format type="text/markdown">
|
||
|
<![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This property corresponds to the "FailoverPartnerSPN" and "Failover Partner SPN" keys within the connection string.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> This property only applies when using Integrated Security mode, otherwise it is ignored.
|
||
|
|
||
|
]]>
|
||
|
</format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.InitialCatalog">
|
||
|
<summary>Gets or sets the name of the database associated with the connection.</summary><value>The value of the <see cref="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.InitialCatalog" /> property, or <see langword="String.Empty" /> if none has been supplied.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This property corresponds to the "Initial Catalog" and "database" keys within the connection string.
|
||
|
|
||
|
The database name can be 128 characters or less.
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a simple connection string and then uses the <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder> class to add the name of the database to the connection string. The code displays the contents of the <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.InitialCatalog%2A> property, just to verify that the class was able to convert from the synonym ("Database") to the appropriate property value.
|
||
|
|
||
|
[!code-csharp[SqlConnectionStringBuilder_InitialCatalog#1](~/../sqlclient/doc/samples/SqlConnectionStringBuilder_InitialCatalog.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">To set the value to null, use <see cref="F:System.DBNull.Value" />.</exception>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.IntegratedSecurity">
|
||
|
<summary>Gets or sets a Boolean value that indicates whether User ID and Password are specified in the connection (when <see langword="false" />) or whether the current Windows account credentials are used for authentication (when <see langword="true" />).</summary><value>The value of the <see cref="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.IntegratedSecurity" /> property, or <see langword="false" /> if none has been supplied.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This property corresponds to the "Integrated Security" and "trusted_connection" keys within the connection string.
|
||
|
|
||
|
If User ID and Password are specified and Integrated Security is set to true, the User ID and Password will be ignored and Integrated Security will be used.
|
||
|
|
||
|
<xref:Microsoft.Data.SqlClient.SqlCredential> is a more secure way to specify credentials for a connection that uses SQL Server Authentication (`Integrated Security=false`).
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example converts an existing connection string from using SQL Server Authentication to using integrated security. The example does its work by removing the user name and password from the connection string and then setting the <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.IntegratedSecurity%2A> property of the <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder> object.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> This example includes a password to demonstrate how <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder> works with connection strings. In your applications, we recommend that you use Windows Authentication. If you must use a password, do not include a hard-coded password in your application.
|
||
|
|
||
|
[!code-csharp[SqlConnectionStringBuilder_IntegratedSecurity#1](~/../sqlclient/doc/samples/SqlConnectionStringBuilder_IntegratedSecurity.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.IsFixedSize">
|
||
|
<summary>Gets a value that indicates whether the <see cref="T:Microsoft.Data.SqlClient.SqlConnectionStringBuilder" /> has a fixed size.</summary><value>
|
||
|
<see langword="true" /> in every case, because the <see cref="T:Microsoft.Data.SqlClient.SqlConnectionStringBuilder" /> supplies a fixed-size collection of key/value pairs.</value><remarks>To be added.</remarks><related type="Article" href="https://msdn.microsoft.com/library/745c5f95-2f02-4674-b378-6d51a7ec2490">Working with Connection Strings</related><related type="Article" href="/sql/connect/ado-net/overview-sqlclient-driver">Overview of the SqlClient driver</related>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.Item(System.String)">
|
||
|
<param name="keyword">The key of the item to get or set.</param><summary>Gets or sets the value associated with the specified key. In C#, this property is the indexer.</summary><value>The value associated with the specified key.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Because the <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder> contains a fixed-size dictionary, trying to add a key that does not exist within the dictionary throws a <xref:System.Collections.Generic.KeyNotFoundException>.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following code, in a console application, creates a new <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder> and adds key/value pairs to its connection string, using the <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.Item%2A> property.
|
||
|
|
||
|
[!code-csharp[SqlConnectionStringBuilder2#1](~/../sqlclient/doc/samples/SqlConnectionStringBuilder2.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">
|
||
|
<paramref name="keyword" /> is a null reference (<see langword="Nothing" /> in Visual Basic).</exception><exception cref="T:System.Collections.Generic.KeyNotFoundException">Tried to add a key that does not exist within the available keys.</exception><exception cref="T:System.FormatException">Invalid value within the connection string (specifically, a Boolean or numeric value was expected but not supplied).</exception>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.Keys">
|
||
|
<summary>Gets an <see cref="T:System.Collections.ICollection" /> that contains the keys in the <see cref="T:Microsoft.Data.SqlClient.SqlConnectionStringBuilder" />.</summary><value>An <see cref="T:System.Collections.ICollection" /> that contains the keys in the <see cref="T:Microsoft.Data.SqlClient.SqlConnectionStringBuilder" />.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The order of the values in the <xref:System.Collections.ICollection> is unspecified, but it is the same order as the associated values in the <xref:System.Collections.ICollection> returned by the <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.Values%2A> property.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following console application example creates a new <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder>. The code loops through the <xref:System.Collections.ICollection> returned by the <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.Keys%2A> property displaying the key/value pairs.
|
||
|
|
||
|
[!code-csharp[SqlConnectionStringBuilder_Keys#1](~/../sqlclient/doc/samples/SqlConnectionStringBuilder_Keys.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><altmember cref="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.Values" /><altmember cref="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.Item(System.String)" />
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.LoadBalanceTimeout">
|
||
|
<summary>Gets or sets the minimum time, in seconds, for the connection to live in the connection pool before being destroyed.</summary><value>The value of the <see cref="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.LoadBalanceTimeout" /> property, or 0 if none has been supplied.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This property corresponds to the "Load Balance Timeout" and "connection lifetime" keys within the connection string.
|
||
|
|
||
|
When a connection is returned to the pool, its creation time is compared with the current time, and the connection is destroyed if that time span (in seconds) exceeds the value specified by `Connection Lifetime`. This is useful in clustered configurations to force load balancing between a running server and a server just brought online.
|
||
|
|
||
|
A value of zero (0) causes pooled connections to have the maximum connection timeout.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.MaxPoolSize">
|
||
|
<summary>Gets or sets the maximum number of connections allowed in the connection pool for this specific connection string.</summary><value>The value of the <see cref="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.MaxPoolSize" /> property, or 100 if none has been supplied.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This property corresponds to the "Max Pool Size" key within the connection string.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.MinPoolSize">
|
||
|
<summary>Gets or sets the minimum number of connections allowed in the connection pool for this specific connection string.</summary><value>The value of the <see cref="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.MinPoolSize" /> property, or 0 if none has been supplied.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This property corresponds to the "Min Pool Size" key within the connection string.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.MultipleActiveResultSets">
|
||
|
<summary>When true, an application can maintain multiple active result sets (MARS). When false, an application must process or cancel all result sets from one batch before it can execute any other batch on that connection. For more information, see [Multiple Active Result Sets (MARS)](https://msdn.microsoft.com//library/cfa084cz.aspx).</summary><value>The value of the <see cref="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.MultipleActiveResultSets" /> property, or <see langword="false" /> if none has been supplied.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This property corresponds to the "Multiple Active Result Sets" key within the connection string.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example explicitly enables the Multiple Active Result Sets feature.
|
||
|
|
||
|
[!code-csharp[SqlConnectionStringBuilder_MultipleActiveResultSets.MARS#1](~/../sqlclient/doc/samples/SqlConnectionStringBuilder_MultipleActiveResultSets.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.MultiSubnetFailover">
|
||
|
<summary>If your application is connecting to an AlwaysOn availability group (AG) on different subnets, setting MultiSubnetFailover=true provides faster detection of and connection to the (currently) active server. For more information about SqlClient support for Always On Availability Groups, see [SqlClient Support for High Availability, Disaster Recovery](/sql/connect/ado-net/sql/sqlclient-support-high-availability-disaster-recovery).</summary><value>Returns <see cref="T:System.Boolean" /> indicating the current value of the property.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Always specify `multiSubnetFailover=True` when connecting to the availability group listener of a SQL Server 2012 (or later) availability group or a SQL Server 2012 (or later) Failover Cluster Instance.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.PacketSize">
|
||
|
<summary>Gets or sets the size in bytes of the network packets used to communicate with an instance of SQL Server.</summary><value>The value of the <see cref="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.PacketSize" /> property, or 8000 if none has been supplied.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This property corresponds to the "Packet Size" key within the connection string.
|
||
|
|
||
|
The packet size can be greater than or equal to 512 and less than or equal to 32768.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.Password">
|
||
|
<summary>Gets or sets the password for the SQL Server account.</summary><value>The value of the <see cref="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.Password" /> property, or <see langword="String.Empty" /> if none has been supplied.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This property corresponds to the "Password" and "pwd" keys within the connection string.
|
||
|
|
||
|
Setting this property is not recommended. To maintain a high level of security, we strongly recommend that you use the `Integrated Security` or `Trusted_Connection` keyword instead. <xref:Microsoft.Data.SqlClient.SqlCredential> is a more secure way to specify credentials for a connection that uses SQL Server Authentication.
|
||
|
|
||
|
If <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.Password%2A> has not been set and you retrieve the value, the return value is <xref:System.String.Empty>. To reset the password for the connection string, pass null to the Item property.
|
||
|
|
||
|
The password must be 128 characters or less.
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example shows how to set <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.Password%2A>.
|
||
|
|
||
|
[!code-csharp[SqlConnectionStringBuilder_Password#1](~/../sqlclient/doc/samples/SqlConnectionStringBuilder_Password.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">The password was incorrectly set to null. See code sample below.</exception>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.PersistSecurityInfo">
|
||
|
<summary>Gets or sets a Boolean value indicating if security-sensitive information, such as the password or access token, should be returned as part of the connection string on a connection created with this <see cref="T:Microsoft.Data.SqlClient.SqlConnectionStringBuilder" /> after that connection has ever been in an open state. This property should only be set to <see langword="true" /> if your application has a specific need to read the password out of an already-opened database connection. The default value of <see langword="false" /> is the more secure setting; using <see langword="true" /> for this property opens your application to security risks such as accidentally logging or tracing the database password.</summary><value>The value of the <see cref="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.PersistSecurityInfo" /> property, or <see langword="false" /> if none has been supplied.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This property corresponds to the "Persist Security Info" and "persistsecurityinfo" keys within the connection string.
|
||
|
|
||
|
Resetting the connection string resets all connection string values including the password.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.PoolBlockingPeriod">
|
||
|
<summary>The blocking period behavior for a connection pool.</summary><value>The available blocking period settings.</value><remarks>
|
||
|
<format type="text/markdown">
|
||
|
<![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This property corresponds to the "Pool Blocking Period" key within the connection string.
|
||
|
|
||
|
When connection pooling is enabled and a timeout error or other login error occurs, an exception will be thrown and subsequent connection attempts will fail for the next five seconds, the "blocking period". If the application attempts to connect within the blocking period, the first exception will be thrown again. Subsequent failures after a blocking period ends will result in a new blocking period that is twice as long as the previous blocking period, up to a maximum of one minute.
|
||
|
|
||
|
Attempting to connect to Azure SQL databases can fail with transient errors which are typically recovered within a few seconds. However, with the connection pool blocking period behavior, you may not be able to reach your database for extensive periods even though the database is available. This is especially problematic for apps that need to render fast. The **PoolBlockingPeriod** enables you to select the blocking period best suited for your app. See the <xref:Microsoft.Data.SqlClient.PoolBlockingPeriod> enumeration for available settings.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.Pooling">
|
||
|
<summary>Gets or sets a Boolean value that indicates whether the connection will be pooled or explicitly opened every time that the connection is requested.</summary><value>The value of the <see cref="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.Pooling" /> property, or <see langword="true" /> if none has been supplied.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This property corresponds to the "Pooling" key within the connection string.
|
||
|
|
||
|
Connections are considered the same if they have the same connection string. Different connections have different connection strings.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.Replication">
|
||
|
<summary>Gets or sets a Boolean value that indicates whether replication is supported using the connection.</summary><value>The value of the <see cref="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.Replication" /> property, or false if none has been supplied.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This property corresponds to the "Replication" key within the connection string.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.ServerSPN">
|
||
|
<summary>Gets or sets the service principal name (SPN) of the data source.</summary><value>
|
||
|
The value of the <see cref="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.ServerSPN" /> property, or <see langword="String.Empty" /> if none has been supplied.
|
||
|
</value><remarks>
|
||
|
<format type="text/markdown">
|
||
|
<![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This property corresponds to the "ServerSPN" and "Server SPN" keys within the connection string.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> This property only applies when using Integrated Security mode, otherwise it is ignored.
|
||
|
|
||
|
]]>
|
||
|
</format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.TransactionBinding">
|
||
|
<summary>Gets or sets a string value that indicates how the connection maintains its association with an enlisted <see langword="System.Transactions" /> transaction.</summary><value>The value of the <see cref="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.TransactionBinding" /> property, or `Implicit Unbind` if none has been supplied.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The Transaction Binding keywords in a <xref:Microsoft.Data.SqlClient.SqlConnection.ConnectionString%2A> control how a <xref:Microsoft.Data.SqlClient.SqlConnection> binds to an enlisted <xref:System.Transactions.Transaction>.
|
||
|
|
||
|
The following table shows the possible values for the <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.TransactionBinding%2A> property:
|
||
|
|
||
|
|Value|Description|
|
||
|
|-----------|-----------------|
|
||
|
|Implicit Unbind|The default. Causes the connection to detach from the transaction when it ends. After detaching, additional requests on the connection are performed in autocommit mode. The <xref:System.Transactions.Transaction.Current%2A> property is not checked when executing requests while the transaction is active. After the transaction has ended, additional requests are performed in autocommit mode.|
|
||
|
|Explicit Unbind|Causes the connection to remain attached to the transaction until the connection is closed or until <xref:Microsoft.Data.SqlClient.SqlConnection.EnlistTransaction%2A> is called with a `null` (`Nothing` in Visual Basic) value. An <xref:System.InvalidOperationException> is thrown if <xref:System.Transactions.Transaction.Current%2A> is not the enlisted transaction or if the enlisted transaction is not active. This behavior enforces the strict scoping rules required for <xref:System.Transactions.TransactionScope> support.|
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.TrustServerCertificate">
|
||
|
<summary>Gets or sets a value that indicates whether the channel will be encrypted while bypassing walking the certificate chain to validate trust.</summary><value>A boolean. The default is `false`.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This property corresponds to the "Trust Server Certificate" and "TrustServerCertificate" keys within the connection string.
|
||
|
|
||
|
When `Trust Server Certificate` is set to `true`, the transport layer will use TLS to encrypt the channel and bypass walking the certificate chain to validate trust. If `Trust Server Certificate` is set to `true` and encryption is enforced by target server, the encryption level specified on the server will be used even if `Encrypt` is set to `false`. The connection will fail otherwise.
|
||
|
|
||
|
For more information, see [Encryption Hierarchy](/sql/relational-databases/security/encryption/encryption-hierarchy) and [Using Encryption Without Validation](/sql/relational-databases/native-client/features/using-encryption-without-validation).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.TypeSystemVersion">
|
||
|
<summary>Gets or sets a string value that indicates the type system the application expects.</summary><value>The following table shows the possible values for the <see cref="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.TypeSystemVersion" /> property:
|
||
|
|
||
|
<list type="table"><listheader><term> Value
|
||
|
|
||
|
</term><description> Description
|
||
|
|
||
|
</description></listheader><item><term> SQL Server 2005
|
||
|
|
||
|
</term><description> Uses the SQL Server 2005 type system. No conversions are made for the current version of ADO.NET.
|
||
|
|
||
|
</description></item><item><term> SQL Server 2008
|
||
|
|
||
|
</term><description> Uses the SQL Server 2008 type system.
|
||
|
|
||
|
</description></item><item><term> Latest
|
||
|
|
||
|
</term><description> Use the latest version than this client-server pair can handle. This will automatically move forward as the client and server components are upgraded.
|
||
|
|
||
|
</description></item></list></value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The `TypeSystemVersion` property can be used to specify a down-level version of SQL Server for applications written against that version. This avoids possible problems with incompatible types in a newer version of SQL Server that may cause the application to break.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.UserID">
|
||
|
<summary>Gets or sets the user ID to be used when connecting to SQL Server.</summary><value>The value of the <see cref="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.UserID" /> property, or <see langword="String.Empty" /> if none has been supplied.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This property corresponds to the "User ID", "user", and "uid" keys within the connection string.
|
||
|
|
||
|
Setting this property is not recommended. To maintain a high level of security, we strongly recommend that you use the `Integrated Security` or `Trusted_Connection` keywords instead. <xref:Microsoft.Data.SqlClient.SqlCredential> is a more secure way to specify credentials for a connection that uses SQL Server Authentication.
|
||
|
|
||
|
The user ID must be 128 characters or less.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">To set the value to null, use <see cref="F:System.DBNull.Value" />.</exception>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.UserInstance">
|
||
|
<summary>Gets or sets a value that indicates whether to redirect the connection from the default SQL Server Express instance to a runtime-initiated instance running under the account of the caller.</summary><value>The value of the <see cref="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.UserInstance" /> property, or <see langword="False" /> if none has been supplied.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This property corresponds to the "User Instance" key within the connection string.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> This feature is available only with the SQL Server Express Edition. For more information on user instances, see [SQL Server Express User Instances](/sql/connect/ado-net/sql/sql-server-express-user-instances).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">To set the value to null, use <see cref="F:System.DBNull.Value" />.</exception>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.Values">
|
||
|
<summary>Gets an <see cref="T:System.Collections.ICollection" /> that contains the values in the <see cref="T:Microsoft.Data.SqlClient.SqlConnectionStringBuilder" />.</summary><value>An <see cref="T:System.Collections.ICollection" /> that contains the values in the <see cref="T:Microsoft.Data.SqlClient.SqlConnectionStringBuilder" />.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The order of the values in the <xref:System.Collections.ICollection> is unspecified, but it is the same order as the associated keys in the <xref:System.Collections.ICollection> returned by the <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.Keys%2A> property. Because each instance of the <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder> always contains the same fixed set of keys, the <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.Values%2A> property always returns the values corresponding to the fixed set of keys, in the same order as the keys.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example first creates a new <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder>, and then iterates through all the values within the object.
|
||
|
|
||
|
[!code-csharp[SqlConnectionStringBuilder_Values#1](~/../sqlclient/doc/samples/SqlConnectionStringBuilder_Values.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><altmember cref="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.Keys" />
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.WorkstationID">
|
||
|
<summary>Gets or sets the name of the workstation connecting to SQL Server.</summary><value>The value of the <see cref="P:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.WorkstationID" /> property, or <see langword="String.Empty" /> if none has been supplied.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This property corresponds to the "Workstation ID" and "wsid" keys within the connection string.
|
||
|
|
||
|
The ID must be 128 characters or less.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">To set the value to null, use <see cref="F:System.DBNull.Value" />.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.Clear">
|
||
|
<summary>Clears the contents of the <see cref="T:Microsoft.Data.SqlClient.SqlConnectionStringBuilder" /> instance.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:System.Data.Common.DbConnectionStringBuilder.Clear%2A> method removes all key/value pairs from the <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder>, and resets all corresponding properties. This includes setting the <xref:System.Data.Common.DbConnectionStringBuilder.Count%2A> property to 0, and setting the <xref:System.Data.Common.DbConnectionStringBuilder.ConnectionString%2A> property to an empty string.
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example demonstrates calling the <xref:System.Data.Common.DbConnectionStringBuilder.Clear%2A> method. This example populates the <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder> with some key/value pairs, and then calls the <xref:System.Data.Common.DbConnectionStringBuilder.Clear%2A> method and shows the results.
|
||
|
|
||
|
[!code-csharp[DataWorks SqlConnectionStringBuilder_Clear#1](~/../sqlclient/doc/samples/SqlConnectionStringBuilder_Clear.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.ContainsKey(System.String)">
|
||
|
<param name="keyword">The key to locate in the <see cref="T:Microsoft.Data.SqlClient.SqlConnectionStringBuilder" />.</param><summary>Determines whether the <see cref="T:Microsoft.Data.SqlClient.SqlConnectionStringBuilder" /> contains a specific key.</summary><returns>true if the <see cref="T:Microsoft.Data.SqlClient.SqlConnectionStringBuilder" /> contains an element that has the specified key; otherwise, false.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Because the <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder> contains a fixed-size collection of key/value pairs, the <xref:System.Data.Common.DbConnectionStringBuilder.ContainsKey%2A> method determines only if a particular key name is valid.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder> instance, sets some of its properties, and then tries to determine whether various keys exist within the object by calling the **ContainsKey** method.
|
||
|
|
||
|
[!code-csharp[SqlConnectionStringBuilder_ContainsKey#1](~/../sqlclient/doc/samples/SqlConnectionStringBuilder_ContainsKey.cs#1)]
|
||
|
|
||
|
The example displays the following output in the console window:
|
||
|
|
||
|
```
|
||
|
Connection string = Data Source=(local);Initial Catalog=AdventureWorks;Integrated Security=True
|
||
|
True
|
||
|
True
|
||
|
True
|
||
|
False
|
||
|
```
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">
|
||
|
<paramref name="keyword" /> is null (<see langword="Nothing" /> in Visual Basic)</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.Remove(System.String)">
|
||
|
<param name="keyword">The key of the key/value pair to be removed from the connection string in this <see cref="T:Microsoft.Data.SqlClient.SqlConnectionStringBuilder" />.</param><summary>Removes the entry with the specified key from the <see cref="T:Microsoft.Data.SqlClient.SqlConnectionStringBuilder" /> instance.</summary><returns>
|
||
|
<see langword="true" /> if the key existed within the connection string and was removed; <see langword="false" /> if the key did not exist.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Because the **Remove** method returns a value that indicates its success, it is not required to look for a key before trying to remove the key/value pair from the <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder> instance. Because the <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder> maintains a fixed-size collection of key/value pairs, calling the <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.Remove%2A> method simply resets the value of the key/value pair back to its default value.
|
||
|
|
||
|
Because the collection of keys supported by the <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder> is fixed, every item within the collection has a known default value. The following table lists the keys, and the value for each when the <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder> is first initialized, or after the <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.Remove%2A> method has been called.
|
||
|
|
||
|
|Key|Default value|
|
||
|
|---------|-------------------|
|
||
|
|Application Name|"Framework Microsoft SqlClient Data Provider" when running on .NET Framework. "Core Microsoft SqlClient Data Provider" otherwise.|
|
||
|
|AttachDBFilename|Empty string|
|
||
|
|Connection Timeout|15|
|
||
|
|Context Connection(Obsolete)|False|
|
||
|
|Current Language|Empty string|
|
||
|
|Data Source|Empty string|
|
||
|
|Encrypt|False in versions prior to 4.0, True in versions 4.0 and up|
|
||
|
|Enlist|True|
|
||
|
|Failover Partner|Empty string|
|
||
|
|Initial Catalog|Empty string|
|
||
|
|Integrated Security|False|
|
||
|
|Load Balance Timeout|0|
|
||
|
|Max Pool Size|100|
|
||
|
|Min Pool Size|0|
|
||
|
|MultipleActiveResultSets|False|
|
||
|
|Network Library|Empty string|
|
||
|
|Packet Size|8000|
|
||
|
|Password|Empty string|
|
||
|
|Persist Security Info|False|
|
||
|
|Pooling|True|
|
||
|
|Replication|False|
|
||
|
|Transaction Binding|Implicit Unbind|
|
||
|
|User ID|Empty string|
|
||
|
|User Instance|False|
|
||
|
|Workstation ID|Empty string|
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example converts an existing connection string from using Windows Authentication to using integrated security. The example works by removing the user name and password from the connection string, and then setting the <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.IntegratedSecurity%2A> property of the <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder> object.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> This example includes a password to demonstrate how <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder> works with connection strings. In your applications, we recommend that you use Windows Authentication. If you must use a password, do not include a hard-coded password in your application.
|
||
|
|
||
|
[!code-csharp[SqlConnectionStringBuilder_Remove#1](~/../sqlclient/doc/samples/SqlConnectionStringBuilder_Remove.cs#1)]
|
||
|
|
||
|
The example displays the following text in the console window:
|
||
|
|
||
|
```
|
||
|
Original: Data Source=(local);Initial Catalog=AdventureWorks;User ID=ab;Password= a1Pass@@11
|
||
|
Modified: Data Source=(local);Initial Catalog=AdventureWorks;Integrated Security=True
|
||
|
Database = AdventureWorks
|
||
|
```
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">
|
||
|
<paramref name="keyword" /> is null (<see langword="Nothing" /> in Visual Basic)</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.ShouldSerialize(System.String)">
|
||
|
<param name="keyword">The key to locate in the <see cref="T:Microsoft.Data.SqlClient.SqlConnectionStringBuilder" />.</param><summary>Indicates whether the specified key exists in this <see cref="T:Microsoft.Data.SqlClient.SqlConnectionStringBuilder" /> instance.</summary><returns>
|
||
|
<see langword="true" /> if the <see cref="T:Microsoft.Data.SqlClient.SqlConnectionStringBuilder" /> contains an entry with the specified key; otherwise, <see langword="false" />.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This method behaves identically to the <xref:System.Data.Common.DbConnectionStringBuilder.ContainsKey%2A> method.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.TryGetValue(System.String,System.Object@)">
|
||
|
<param name="keyword">The key of the item to retrieve.</param><param name="value">The value corresponding to <paramref name="keyword" />.</param><summary>Retrieves a value corresponding to the supplied key from this <see cref="T:Microsoft.Data.SqlClient.SqlConnectionStringBuilder" />.</summary><returns>
|
||
|
<see langword="true" /> if <paramref name="keyword" /> was found within the connection string; otherwise, <see langword="false" />.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder.TryGetValue%2A> method lets developers safely retrieve a value from a <xref:Microsoft.Data.SqlClient.SqlConnectionStringBuilder> without needing to verify that the supplied key name is a valid key name. Because **TryGetValue** does not raise an exception when you call it, passing in a nonexistent key, you do not have to look for a key before retrieving its value. Calling **TryGetValue** with a nonexistent key will place the value null (`Nothing` in Visual Basic) in the `value` parameter.
|
||
|
|
||
|
## Examples
|
||
|
The following example demonstrates the behavior of the **TryGetValue** method.
|
||
|
|
||
|
[!code-csharp[SqlConnectionStringBuilder_TryGetValue#1](~/../sqlclient/doc/samples/SqlConnectionStringBuilder_TryGetValue.cs#1)]
|
||
|
|
||
|
The sample displays the following results:
|
||
|
|
||
|
```
|
||
|
Data Source=(local)
|
||
|
Trusted_Connection=True
|
||
|
Unable to retrieve value for 'InvalidKey'
|
||
|
Unable to retrieve value for null key.
|
||
|
```
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">
|
||
|
<paramref name="keyword" /> contains a null value (<see langword="Nothing" /> in Visual Basic).</exception>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlCredential">
|
||
|
<summary>
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlCredential" /> provides a more secure way to specify the password for a login attempt using SQL Server Authentication.
|
||
|
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlCredential" /> is comprised of a user id and a password that will be used for SQL Server Authentication. The password in a <see cref="T:Microsoft.Data.SqlClient.SqlCredential" /> object is of type <see cref="T:System.Security.SecureString" />.
|
||
|
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlCredential" /> cannot be inherited.
|
||
|
|
||
|
Windows Authentication (<see langword="Integrated Security = true" />) remains the most secure way to log in to a SQL Server database.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Use <xref:Microsoft.Data.SqlClient.SqlConnection.Credential%2A> to get or set a connection's <xref:Microsoft.Data.SqlClient.SqlCredential> object. Use <xref:Microsoft.Data.SqlClient.SqlConnection.ChangePassword%2A> to change the password for a <xref:Microsoft.Data.SqlClient.SqlCredential> object. For information on how a <xref:Microsoft.Data.SqlClient.SqlCredential> object affects connection pool behavior, see [SQL Server Connection Pooling (ADO.NET)](/sql/connect/ado-net/sql-server-connection-pooling).
|
||
|
|
||
|
An <xref:System.InvalidOperationException> exception will be raised if a non-null <xref:Microsoft.Data.SqlClient.SqlCredential> object is used in a connection with any of the following connection string keywords:
|
||
|
|
||
|
- `Integrated Security = true`
|
||
|
|
||
|
- `Password`
|
||
|
|
||
|
- `User ID`
|
||
|
|
||
|
The following sample connects to a SQL Server database using <xref:Microsoft.Data.SqlClient.SqlConnection.Credential%2A>:
|
||
|
|
||
|
```
|
||
|
// change connection string in the APP.CONFIG file
|
||
|
<connectionStrings>
|
||
|
<add name="MyConnString"
|
||
|
connectionString="Initial Catalog=myDB;Server=myServer"
|
||
|
providerName="Microsoft.Data.SqlClient" />
|
||
|
</connectionStrings>
|
||
|
|
||
|
// then use the following snippet:
|
||
|
using System.Configuration;
|
||
|
|
||
|
System.Windows.Controls.TextBox txtUserId = new System.Windows.Controls.TextBox();
|
||
|
System.Windows.Controls.PasswordBox txtPwd = new System.Windows.Controls.PasswordBox();
|
||
|
|
||
|
Configuration config = Configuration.WebConfigurationManager.OpenWebConfiguration(Null);
|
||
|
ConnectionStringSettings connString = config.ConnectionStrings.ConnectionString["MyConnString"];
|
||
|
|
||
|
using (SqlConnection conn = new SqlConnection(connString.ConnectionString))
|
||
|
{
|
||
|
SecureString pwd = txtPwd.SecurePassword;
|
||
|
pwd.MakeReadOnly();
|
||
|
SqlCredential cred = new SqlCredential(txtUserId.Text, pwd);
|
||
|
conn.Credential = cred;
|
||
|
conn.Open();
|
||
|
}
|
||
|
```
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlCredential.#ctor(System.String,System.Security.SecureString)">
|
||
|
<param name="userId">The user id.</param><param name="password">The password; a <see cref="T:System.Security.SecureString" /> value marked as read-only. Passing a read/write <see cref="T:System.Security.SecureString" /> parameter will raise an <see cref="T:System.ArgumentException" />.</param><summary>Creates an object of type <see cref="T:Microsoft.Data.SqlClient.SqlCredential" />.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The constructor does not accept null parameters. A <xref:System.String.Empty> value is allowed. An attempt to pass a null parameter in the constructor will raise an <xref:System.ArgumentNullException> exception.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><related type="Article" href="/sql/connect/ado-net/overview-sqlclient-driver">Overview of the SqlClient driver</related>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlCredential.Password">
|
||
|
<summary>Gets the password component of the <see cref="T:Microsoft.Data.SqlClient.SqlCredential" /> object.</summary><value>The password component of the <see cref="T:Microsoft.Data.SqlClient.SqlCredential" /> object.</value><remarks>To be added.</remarks><related type="Article" href="/sql/connect/ado-net/overview-sqlclient-driver">Overview of the SqlClient driver</related>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlCredential.UserId">
|
||
|
<summary>Gets the user ID component of the <see cref="T:Microsoft.Data.SqlClient.SqlCredential" /> object.</summary><value>The user ID component of the <see cref="T:Microsoft.Data.SqlClient.SqlCredential" /> object.</value><remarks>To be added.</remarks><related type="Article" href="/sql/connect/ado-net/overview-sqlclient-driver">Overview of the SqlClient driver</related>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlDataAdapter">
|
||
|
<summary>Represents a set of data commands and a database connection that are used to fill the <see cref="T:System.Data.DataSet" /> and update a SQL Server database. This class cannot be inherited.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlDataAdapter>, serves as a bridge between a <xref:System.Data.DataSet> and SQL Server for retrieving and saving data. The <xref:Microsoft.Data.SqlClient.SqlDataAdapter> provides this bridge by mapping <xref:System.Data.Common.DbDataAdapter.Fill%2A>, which changes the data in the <xref:System.Data.DataSet> to match the data in the data source, and <xref:System.Data.Common.DbDataAdapter.Update%2A>, which changes the data in the data source to match the data in the <xref:System.Data.DataSet>, using the appropriate Transact-SQL statements against the data source. The update is performed on a by-row basis. For every inserted, modified, and deleted row, the <xref:System.Data.Common.DbDataAdapter.Update%2A> method determines the type of change that has been performed on it (`Insert`, `Update`, or `Delete`). Depending on the type of change, the `Insert`, `Update`, or `Delete` command template executes to propagate the modified row to the data source. When the <xref:Microsoft.Data.SqlClient.SqlDataAdapter> fills a <xref:System.Data.DataSet>, it creates the necessary tables and columns for the returned data if they do not already exist. However, primary key information is not included in the implicitly created schema unless the <xref:System.Data.Common.DataAdapter.MissingSchemaAction%2A> property is set to <xref:System.Data.MissingSchemaAction.AddWithKey>. You may also have the <xref:Microsoft.Data.SqlClient.SqlDataAdapter> create the schema of the <xref:System.Data.DataSet>, including primary key information, before filling it with data using `FillSchema`. For more information, see [Adding Existing Constraints to a DataSet](/sql/connect/ado-net/add-existing-constraints-to-dataset).
|
||
|
|
||
|
<xref:Microsoft.Data.SqlClient.SqlDataAdapter> is used in conjunction with <xref:Microsoft.Data.SqlClient.SqlConnection> and <xref:Microsoft.Data.SqlClient.SqlCommand> to increase performance when connecting to a SQL Server database.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> If you are using SQL Server stored procedures to edit or delete data using a `DataAdapter`, make sure that you do not use SET NOCOUNT ON in the stored procedure definition. This causes the rows affected count returned to be zero, which the `DataAdapter` interprets as a concurrency conflict. In this event, a <xref:System.Data.DBConcurrencyException> will be thrown.
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlDataAdapter> also includes the <xref:Microsoft.Data.SqlClient.SqlDataAdapter.SelectCommand%2A>, <xref:Microsoft.Data.SqlClient.SqlDataAdapter.InsertCommand%2A>, <xref:Microsoft.Data.SqlClient.SqlDataAdapter.DeleteCommand%2A>, <xref:Microsoft.Data.SqlClient.SqlDataAdapter.UpdateCommand%2A>, and <xref:System.Data.Common.DataAdapter.TableMappings%2A> properties to facilitate the loading and updating of data.
|
||
|
|
||
|
When an instance of <xref:Microsoft.Data.SqlClient.SqlDataAdapter> is created, the read/write properties are set to initial values. For a list of these values, see the <xref:Microsoft.Data.SqlClient.SqlDataAdapter> constructor.
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlDataAdapter.InsertCommand%2A>, <xref:Microsoft.Data.SqlClient.SqlDataAdapter.DeleteCommand%2A>, and <xref:Microsoft.Data.SqlClient.SqlDataAdapter.UpdateCommand%2A> are generic templates that are automatically filled with individual values from every modified row through the parameters mechanism.
|
||
|
|
||
|
For every column that you propagate to the data source on <xref:System.Data.Common.DbDataAdapter.Update%2A>, a parameter should be added to the `InsertCommand`, `UpdateCommand`, or `DeleteCommand`. The <xref:System.Data.Common.DbParameter.SourceColumn%2A> property of the <xref:System.Data.Common.DbParameter> object should be set to the name of the column. This setting indicates that the value of the parameter is not set manually, but is taken from the particular column in the currently processed row.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> An <xref:System.InvalidOperationException> will occur if the <xref:System.Data.Common.DbDataAdapter.Fill%2A> method is called and the table contains a user-defined type that is not available on the client computer. For more information, see [CLR User-Defined Types](/sql/relational-databases/clr-integration-database-objects-user-defined-types/clr-user-defined-types).
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example uses the <xref:Microsoft.Data.SqlClient.SqlCommand>, <xref:Microsoft.Data.SqlClient.SqlDataAdapter>, and <xref:Microsoft.Data.SqlClient.SqlConnection> to select records from a database and populate a <xref:System.Data.DataSet> with the selected rows. The filled <xref:System.Data.DataSet> is then returned. To accomplish this, the method is passed an initialized <xref:System.Data.DataSet>, a connection string, and a query string that is a Transact-SQL SELECT statement.
|
||
|
|
||
|
[!code-csharp[SqlDataAdapter_SelectCommand Example#1](~/../sqlclient/doc/samples/SqlDataAdapter_SelectCommand.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataAdapter.#ctor">
|
||
|
<summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.SqlDataAdapter" /> class.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
When an instance of <xref:Microsoft.Data.SqlClient.SqlDataAdapter> is created, the following read/write properties are set to the following initial values.
|
||
|
|
||
|
|Properties|Initial value|
|
||
|
|----------------|-------------------|
|
||
|
|<xref:System.Data.Common.DataAdapter.MissingMappingAction%2A>|`MissingMappingAction.Passthrough`|
|
||
|
|<xref:System.Data.Common.DataAdapter.MissingSchemaAction%2A>|`MissingSchemaAction.Add`|
|
||
|
|
||
|
You can change the value of any of these properties through a separate call to the property.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlDataAdapter> and sets some of its properties.
|
||
|
|
||
|
[!code-csharp[SqlDataAdapter.SqlDataAdapter Example#1](~/../sqlclient/doc/samples/SqlDataAdapter_SqlDataAdapter.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataAdapter.#ctor(Microsoft.Data.SqlClient.SqlCommand)">
|
||
|
<param name="selectCommand">A <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> that is a Transact-SQL SELECT statement or stored procedure and is set as the <see cref="P:Microsoft.Data.SqlClient.SqlDataAdapter.SelectCommand" /> property of the <see cref="T:Microsoft.Data.SqlClient.SqlDataAdapter" />.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.SqlDataAdapter" /> class with the specified <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> as the <see cref="P:Microsoft.Data.SqlClient.SqlDataAdapter.SelectCommand" /> property.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This implementation of the <xref:Microsoft.Data.SqlClient.SqlDataAdapter> constructor sets the <xref:Microsoft.Data.SqlClient.SqlDataAdapter.SelectCommand%2A> property to the value specified in the `selectCommand` parameter.
|
||
|
|
||
|
When an instance of <xref:Microsoft.Data.SqlClient.SqlDataAdapter> is created, the following read/write properties are set to the following initial values.
|
||
|
|
||
|
|Properties|Initial value|
|
||
|
|----------------|-------------------|
|
||
|
|<xref:System.Data.Common.DataAdapter.MissingMappingAction%2A>|`MissingMappingAction.Passthrough`|
|
||
|
|<xref:System.Data.Common.DataAdapter.MissingSchemaAction%2A>|`MissingSchemaAction.Add`|
|
||
|
|
||
|
You can change the value of any of these properties through a separate call to the property.
|
||
|
|
||
|
When <xref:Microsoft.Data.SqlClient.SqlDataAdapter.SelectCommand%2A> (or any of the other command properties) is assigned to a previously created <xref:Microsoft.Data.SqlClient.SqlCommand>, the <xref:Microsoft.Data.SqlClient.SqlCommand> is not cloned. The <xref:Microsoft.Data.SqlClient.SqlDataAdapter.SelectCommand%2A> maintains a reference to the previously created <xref:Microsoft.Data.SqlClient.SqlCommand> object.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlDataAdapter> and sets some of its properties.
|
||
|
|
||
|
[!code-csharp[SqlDataAdapter_SqlDataAdapter1 Example#1](~/../sqlclient/doc/samples/SqlDataAdapter_SqlDataAdapter1.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataAdapter.#ctor(System.String,Microsoft.Data.SqlClient.SqlConnection)">
|
||
|
<param name="selectCommandText">A <see cref="T:System.String" /> that is a Transact-SQL SELECT statement or stored procedure to be used by the <see cref="P:Microsoft.Data.SqlClient.SqlDataAdapter.SelectCommand" /> property of the <see cref="T:Microsoft.Data.SqlClient.SqlDataAdapter" />.</param><param name="selectConnection">A <see cref="T:Microsoft.Data.SqlClient.SqlConnection" /> that represents the connection. If your connection string does not use <see langword="Integrated Security = true" />, you can use <see cref="T:Microsoft.Data.SqlClient.SqlCredential" /> to pass the user ID and password more securely than by specifying the user ID and password as text in the connection string.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.SqlDataAdapter" /> class with a <see cref="P:Microsoft.Data.SqlClient.SqlDataAdapter.SelectCommand" /> and a <see cref="T:Microsoft.Data.SqlClient.SqlConnection" /> object.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This implementation of the <xref:Microsoft.Data.SqlClient.SqlDataAdapter> opens and closes a <xref:Microsoft.Data.SqlClient.SqlConnection> if it is not already open. This can be useful in an application that must call the <xref:System.Data.Common.DbDataAdapter.Fill%2A> method for two or more <xref:Microsoft.Data.SqlClient.SqlDataAdapter> objects. If the <xref:Microsoft.Data.SqlClient.SqlConnection> is already open, you must explicitly call **Close** or **Dispose** to close it.
|
||
|
|
||
|
When an instance of <xref:Microsoft.Data.SqlClient.SqlDataAdapter> is created, the following read/write properties are set to the following initial values.
|
||
|
|
||
|
|Properties|Initial value|
|
||
|
|----------------|-------------------|
|
||
|
|<xref:System.Data.Common.DataAdapter.MissingMappingAction%2A>|`MissingMappingAction.Passthrough`|
|
||
|
|<xref:System.Data.Common.DataAdapter.MissingSchemaAction%2A>|`MissingSchemaAction.Add`|
|
||
|
|
||
|
You can change the value of either of these properties through a separate call to the property.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlDataAdapter> and sets some of its properties.
|
||
|
|
||
|
[!code-csharp[SqlDataAdapter_SqlDataAdapter3 Example#1](~/../sqlclient/doc/samples/SqlDataAdapter_SqlDataAdapter3.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataAdapter.#ctor(System.String,System.String)">
|
||
|
<param name="selectCommandText">A <see cref="T:System.String" /> that is a Transact-SQL SELECT statement or stored procedure to be used by the <see cref="P:Microsoft.Data.SqlClient.SqlDataAdapter.SelectCommand" /> property of the <see cref="T:Microsoft.Data.SqlClient.SqlDataAdapter" />.</param><param name="selectConnectionString">The connection string. If your connection string does not use <see langword="Integrated Security = true" />, you can use <see cref="M:Microsoft.Data.SqlClient.SqlDataAdapter.#ctor(System.String,Microsoft.Data.SqlClient.SqlConnection)" /> and <see cref="T:Microsoft.Data.SqlClient.SqlCredential" /> to pass the user ID and password more securely than by specifying the user ID and password as text in the connection string.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.SqlDataAdapter" /> class with a <see cref="P:Microsoft.Data.SqlClient.SqlDataAdapter.SelectCommand" /> and a connection string.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This overload of the <xref:Microsoft.Data.SqlClient.SqlDataAdapter> constructor uses the `selectCommandText` parameter to set the <xref:Microsoft.Data.SqlClient.SqlDataAdapter.SelectCommand%2A> property. The <xref:Microsoft.Data.SqlClient.SqlDataAdapter> will create and maintain the connection created with the `selectConnectionString` parameter.
|
||
|
|
||
|
When an instance of <xref:Microsoft.Data.SqlClient.SqlDataAdapter> is created, the following read/write properties are set to the following initial values.
|
||
|
|
||
|
|Properties|Initial value|
|
||
|
|----------------|-------------------|
|
||
|
|<xref:System.Data.Common.DataAdapter.MissingMappingAction%2A>|`MissingMappingAction.Passthrough`|
|
||
|
|<xref:System.Data.Common.DataAdapter.MissingSchemaAction%2A>|`MissingSchemaAction.Add`|
|
||
|
|
||
|
You can change the value of any of these properties through a separate call to the property.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlDataAdapter> and sets some of its properties.
|
||
|
|
||
|
[!code-csharp[SqlDataAdapter_SqlDataAdapter2 Example#1](~/../sqlclient/doc/samples/SqlDataAdapter_SqlDataAdapter2.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlDataAdapter.DeleteCommand">
|
||
|
<summary>Gets or sets a Transact-SQL statement or stored procedure to delete records from the data set.</summary><value>A <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> used during <see cref="M:System.Data.Common.DbDataAdapter.Update(System.Data.DataSet)" /> to delete records in the database that correspond to deleted rows in the <see cref="T:System.Data.DataSet" />.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
During <xref:System.Data.Common.DbDataAdapter.Update%2A>, if this property is not set and primary key information is present in the <xref:System.Data.DataSet>, the <xref:Microsoft.Data.SqlClient.SqlDataAdapter.DeleteCommand%2A> can be generated automatically if you set the <xref:Microsoft.Data.SqlClient.SqlDataAdapter.SelectCommand%2A> property and use the <xref:Microsoft.Data.SqlClient.SqlCommandBuilder>. Then, any additional commands that you do not set are generated by the <xref:Microsoft.Data.SqlClient.SqlCommandBuilder>. This generation logic requires key column information to be present in the <xref:System.Data.DataSet>. For more information, see [Generating Commands with CommandBuilders](/sql/connect/ado-net/generate-commands-with-commandbuilders).
|
||
|
|
||
|
When <xref:Microsoft.Data.SqlClient.SqlDataAdapter.DeleteCommand%2A> is assigned to a previously created <xref:Microsoft.Data.SqlClient.SqlCommand>, the <xref:Microsoft.Data.SqlClient.SqlCommand> is not cloned. The <xref:Microsoft.Data.SqlClient.SqlDataAdapter.DeleteCommand%2A> maintains a reference to the previously created <xref:Microsoft.Data.SqlClient.SqlCommand> object.
|
||
|
|
||
|
For every column that you propagate to the data source on <xref:System.Data.Common.DbDataAdapter.Update%2A>, a parameter should be added to the `InsertCommand`, `UpdateCommand`, or `DeleteCommand`. The `SourceColumn` property of the parameter should be set to the name of the column. This indicates that the value of the parameter is not set manually, but is taken from the particular column in the currently processed row.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlDataAdapter> and sets the <xref:Microsoft.Data.SqlClient.SqlDataAdapter.SelectCommand%2A>, <xref:Microsoft.Data.SqlClient.SqlDataAdapter.InsertCommand%2A>, <xref:Microsoft.Data.SqlClient.SqlDataAdapter.UpdateCommand%2A>, and <xref:Microsoft.Data.SqlClient.SqlDataAdapter.DeleteCommand%2A> properties. It assumes you have already created a <xref:Microsoft.Data.SqlClient.SqlConnection> object.
|
||
|
|
||
|
[!code-csharp[SqlDataAdapter#1](~/../sqlclient/doc/samples/SqlDataAdapter.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlDataAdapter.InsertCommand">
|
||
|
<summary>Gets or sets a Transact-SQL statement or stored procedure to insert new records into the data source.</summary><value>A <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> used during <see cref="M:System.Data.Common.DbDataAdapter.Update(System.Data.DataSet)" /> to insert records into the database that correspond to new rows in the <see cref="T:System.Data.DataSet" />.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
During <xref:System.Data.Common.DbDataAdapter.Update%2A>, if this property is not set and primary key information is present in the <xref:System.Data.DataSet>, the <xref:Microsoft.Data.SqlClient.SqlDataAdapter.InsertCommand%2A> can be generated automatically if you set the <xref:Microsoft.Data.SqlClient.SqlDataAdapter.SelectCommand%2A> property and use the <xref:Microsoft.Data.SqlClient.SqlCommandBuilder>. Then, any additional commands that you do not set are generated by the <xref:Microsoft.Data.SqlClient.SqlCommandBuilder>. This generation logic requires key column information to be present in the <xref:System.Data.DataSet>. For more information, see [Generating Commands with CommandBuilders](/sql/connect/ado-net/generate-commands-with-commandbuilders).
|
||
|
|
||
|
When <xref:Microsoft.Data.SqlClient.SqlDataAdapter.InsertCommand%2A> is assigned to a previously created <xref:Microsoft.Data.SqlClient.SqlCommand>, the <xref:Microsoft.Data.SqlClient.SqlCommand> is not cloned. The <xref:Microsoft.Data.SqlClient.SqlDataAdapter.InsertCommand%2A> maintains a reference to the previously created <xref:Microsoft.Data.SqlClient.SqlCommand> object.
|
||
|
|
||
|
If execution of this command returns rows, these rows can be added to the <xref:System.Data.DataSet> depending on how you set the **UpdatedRowSource** property of the <xref:Microsoft.Data.SqlClient.SqlCommand> object.
|
||
|
|
||
|
For every column that you propagate to the data source on <xref:System.Data.Common.DbDataAdapter.Update%2A>, a parameter should be added to `InsertCommand`, `UpdateCommand`, or `DeleteCommand`. The `SourceColumn` property of the parameter should be set to the name of the column. This indicates that the value of the parameter is not set manually, but is taken from the particular column in the currently processed row.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlDataAdapter> and sets the <xref:Microsoft.Data.SqlClient.SqlDataAdapter.SelectCommand%2A>, <xref:Microsoft.Data.SqlClient.SqlDataAdapter.InsertCommand%2A>, <xref:Microsoft.Data.SqlClient.SqlDataAdapter.UpdateCommand%2A>, and <xref:Microsoft.Data.SqlClient.SqlDataAdapter.DeleteCommand%2A> properties. It assumes you have already created a <xref:Microsoft.Data.SqlClient.SqlConnection> object.
|
||
|
|
||
|
[!code-csharp[SqlDataAdapter#1](~/../sqlclient/doc/samples/SqlDataAdapter.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlDataAdapter.SelectCommand">
|
||
|
<summary>Gets or sets a Transact-SQL statement or stored procedure used to select records in the data source.</summary><value>A <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> used during <see cref="M:System.Data.Common.DbDataAdapter.Fill(System.Data.DataSet)" /> to select records from the database for placement in the <see cref="T:System.Data.DataSet" />.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
When <xref:Microsoft.Data.SqlClient.SqlDataAdapter.SelectCommand%2A> is assigned to a previously created <xref:Microsoft.Data.SqlClient.SqlCommand>, the <xref:Microsoft.Data.SqlClient.SqlCommand> is not cloned. The <xref:Microsoft.Data.SqlClient.SqlDataAdapter.SelectCommand%2A> maintains a reference to the previously created <xref:Microsoft.Data.SqlClient.SqlCommand> object.
|
||
|
|
||
|
If the <xref:Microsoft.Data.SqlClient.SqlDataAdapter.SelectCommand%2A> does not return any rows, no tables are added to the <xref:System.Data.DataSet>, and no exception is raised.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlDataAdapter> and sets the <xref:Microsoft.Data.SqlClient.SqlDataAdapter.SelectCommand%2A>, <xref:Microsoft.Data.SqlClient.SqlDataAdapter.InsertCommand%2A>, <xref:Microsoft.Data.SqlClient.SqlDataAdapter.UpdateCommand%2A>, and <xref:Microsoft.Data.SqlClient.SqlDataAdapter.DeleteCommand%2A> properties. It assumes you have already created a <xref:Microsoft.Data.SqlClient.SqlConnection> object.
|
||
|
|
||
|
[!code-csharp[SqlDataAdapter#1](~/../sqlclient/doc/samples/SqlDataAdapter.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlDataAdapter.UpdateBatchSize">
|
||
|
<summary>Gets or sets the number of rows that are processed in each round-trip to the server.</summary><value>The number of rows to process per-batch.
|
||
|
|
||
|
<list type="table"><listheader><term> Value is
|
||
|
|
||
|
</term><description> Effect
|
||
|
|
||
|
</description></listheader><item><term> 0
|
||
|
|
||
|
</term><description> There is no limit on the batch size.
|
||
|
|
||
|
</description></item><item><term> 1
|
||
|
|
||
|
</term><description> Disables batch updating.
|
||
|
|
||
|
</description></item><item><term> >1
|
||
|
|
||
|
</term><description> Changes are sent using batches of <see cref="P:Microsoft.Data.SqlClient.SqlDataAdapter.UpdateBatchSize" /> operations at a time.
|
||
|
|
||
|
</description></item></list>
|
||
|
|
||
|
When setting this to a value other than 1, all the commands associated with the <see cref="T:Microsoft.Data.SqlClient.SqlDataAdapter" /> have to have their **UpdatedRowSource** property set to <see langword="None" /> or <see langword="OutputParameters" />. An exception is thrown otherwise.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Gets or sets a value that enables or disables batch processing support, and specifies the number of commands that can be executed in a batch.
|
||
|
|
||
|
Use the <xref:Microsoft.Data.SqlClient.SqlDataAdapter.UpdateBatchSize%2A> property to update a data source with changes from a <xref:System.Data.DataSet>. This can increase application performance by reducing the number of round-trips to the server.
|
||
|
|
||
|
Executing an extremely large batch could decrease performance. Therefore, you should test for the optimum batch size setting before implementing your application.
|
||
|
|
||
|
An <xref:System.ArgumentOutOfRangeException> is thrown if the value is set to a number less than zero.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlDataAdapter.UpdateCommand">
|
||
|
<summary>Gets or sets a Transact-SQL statement or stored procedure used to update records in the data source.</summary><value>A <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> used during <see cref="M:System.Data.Common.DbDataAdapter.Update(System.Data.DataSet)" /> to update records in the database that correspond to modified rows in the <see cref="T:System.Data.DataSet" />.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
During <xref:System.Data.Common.DbDataAdapter.Update%2A>, if this property is not set and primary key information is present in the <xref:System.Data.DataSet>, the <xref:Microsoft.Data.SqlClient.SqlDataAdapter.UpdateCommand%2A> can be generated automatically if you set the <xref:Microsoft.Data.SqlClient.SqlDataAdapter.SelectCommand%2A> property and use the <xref:Microsoft.Data.SqlClient.SqlCommandBuilder>. Then, any additional commands that you do not set are generated by the <xref:Microsoft.Data.SqlClient.SqlCommandBuilder>. This generation logic requires key column information to be present in the <xref:System.Data.DataSet>. For more information, see [Generating Commands with CommandBuilders](/sql/connect/ado-net/generate-commands-with-commandbuilders).
|
||
|
|
||
|
When <xref:Microsoft.Data.SqlClient.SqlDataAdapter.UpdateCommand%2A> is assigned to a previously created <xref:Microsoft.Data.SqlClient.SqlCommand>, the <xref:Microsoft.Data.SqlClient.SqlCommand> is not cloned. The <xref:Microsoft.Data.SqlClient.SqlDataAdapter.UpdateCommand%2A> maintains a reference to the previously created <xref:Microsoft.Data.SqlClient.SqlCommand> object.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> If execution of this command returns rows, the updated rows may be merged with the <xref:System.Data.DataSet> depending on how you set the **UpdatedRowSource** property of the <xref:Microsoft.Data.SqlClient.SqlCommand> object.
|
||
|
|
||
|
For every column that you propagate to the data source on <xref:System.Data.Common.DbDataAdapter.Update%2A>, a parameter should be added to `InsertCommand`, `UpdateCommand`, or `DeleteCommand`.
|
||
|
|
||
|
The `SourceColumn` property of the parameter should be set to the name of the column. This indicates that the value of the parameter is not set manually, but taken from the particular column in the currently processed row.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlDataAdapter> and sets the <xref:Microsoft.Data.SqlClient.SqlDataAdapter.SelectCommand%2A>, <xref:Microsoft.Data.SqlClient.SqlDataAdapter.InsertCommand%2A>, <xref:Microsoft.Data.SqlClient.SqlDataAdapter.UpdateCommand%2A> and <xref:Microsoft.Data.SqlClient.SqlDataAdapter.DeleteCommand%2A> properties. It assumes you have already created a <xref:Microsoft.Data.SqlClient.SqlConnection> object.
|
||
|
|
||
|
[!code-csharp[SqlDataAdapter#1](~/../sqlclient/doc/samples/SqlDataAdapter.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="E:Microsoft.Data.SqlClient.SqlDataAdapter.RowUpdated">
|
||
|
<summary>Occurs during <see cref="M:System.Data.Common.DbDataAdapter.Update(System.Data.DataSet)" /> after a command is executed against the data source. The attempt to update is made, so the event fires.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
When using <xref:System.Data.Common.DbDataAdapter.Update%2A>, there are two events that occur per data row updated. The order of execution is as follows:
|
||
|
|
||
|
1. The values in the <xref:System.Data.DataRow> are moved to the parameter values.
|
||
|
|
||
|
2. The <xref:System.Data.Common.DbDataAdapter.OnRowUpdating%2A> event is raised.
|
||
|
|
||
|
3. The command executes.
|
||
|
|
||
|
4. If the command is set to `FirstReturnedRecord`, the first returned result is placed in the <xref:System.Data.DataRow>.
|
||
|
|
||
|
5. If there are output parameters, they are placed in the <xref:System.Data.DataRow>.
|
||
|
|
||
|
6. The <xref:System.Data.Common.DbDataAdapter.OnRowUpdated%2A> event is raised.
|
||
|
|
||
|
7. <xref:System.Data.DataRow.AcceptChanges%2A> is called.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example shows how to use both the <xref:Microsoft.Data.SqlClient.SqlDataAdapter.RowUpdating> and <xref:Microsoft.Data.SqlClient.SqlDataAdapter.RowUpdated> events.
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlDataAdapter.RowUpdating> event returns this output:
|
||
|
|
||
|
event args: (command=Microsoft.Data.SqlClient.SqlCommand commandType=2 status=0)
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlDataAdapter.RowUpdated> event returns this output:
|
||
|
|
||
|
event args: (command=Microsoft.Data.SqlClient.SqlCommand commandType=2 recordsAffected=1 row=System.Data.DataRow[37] status=0)
|
||
|
|
||
|
[!code-csharp[SqlDataAdapter_RowUpdated Example#1](~/../sqlclient/doc/samples/SqlDataAdapter_RowUpdated.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="E:Microsoft.Data.SqlClient.SqlDataAdapter.RowUpdating">
|
||
|
<summary>Occurs during <see cref="M:System.Data.Common.DbDataAdapter.Update(System.Data.DataSet)" /> before a command is executed against the data source. The attempt to update is made, so the event fires.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
When using <xref:System.Data.Common.DbDataAdapter.Update%2A>, there are two events that occur per data row updated. The order of execution is as follows:
|
||
|
|
||
|
1. The values in the <xref:System.Data.DataRow> are moved to the parameter values.
|
||
|
|
||
|
2. The <xref:System.Data.Common.DbDataAdapter.OnRowUpdating%2A> event is raised.
|
||
|
|
||
|
3. The command executes.
|
||
|
|
||
|
4. If the command is set to `FirstReturnedRecord`, the first returned result is placed in the <xref:System.Data.DataRow>.
|
||
|
|
||
|
5. If there are output parameters, they are placed in the <xref:System.Data.DataRow>.
|
||
|
|
||
|
6. The <xref:System.Data.Common.DbDataAdapter.OnRowUpdated%2A> event is raised.
|
||
|
|
||
|
7. <xref:System.Data.DataRow.AcceptChanges%2A> is called.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example shows how to use both the <xref:Microsoft.Data.SqlClient.SqlDataAdapter.RowUpdating> and <xref:Microsoft.Data.SqlClient.SqlDataAdapter.RowUpdated> events.
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlDataAdapter.RowUpdating> event returns this output:
|
||
|
|
||
|
event args: (command=Microsoft.Data.SqlClient.SqlCommand commandType=2 status=0)
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlDataAdapter.RowUpdated> event returns this output:
|
||
|
|
||
|
event args: (command=Microsoft.Data.SqlClient.SqlCommand commandType=2 recordsAffected=1 row=System.Data.DataRow[37] status=0)
|
||
|
|
||
|
[!code-csharp[SqlDataAdapter_RowUpdated Example#1](~/../sqlclient/doc/samples/SqlDataAdapter_RowUpdated.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataAdapter.OnRowUpdated(System.Data.Common.RowUpdatedEventArgs)">
|
||
|
<param name="value">To be added.</param><summary>To be added.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataAdapter.OnRowUpdating(System.Data.Common.RowUpdatingEventArgs)">
|
||
|
<param name="value">To be added.</param><summary>To be added.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlDataReader">
|
||
|
<summary>Provides a way of reading a forward-only stream of rows from a SQL Server database. This class cannot be inherited.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
To create a <xref:Microsoft.Data.SqlClient.SqlDataReader>, you must call the <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteReader%2A> method of the <xref:Microsoft.Data.SqlClient.SqlCommand> object, instead of directly using a constructor.
|
||
|
|
||
|
While the <xref:Microsoft.Data.SqlClient.SqlDataReader> is being used, the associated <xref:Microsoft.Data.SqlClient.SqlConnection> is busy serving the <xref:Microsoft.Data.SqlClient.SqlDataReader>, and no other operations can be performed on the <xref:Microsoft.Data.SqlClient.SqlConnection> other than closing it. This is the case until the <xref:Microsoft.Data.SqlClient.SqlDataReader.Close%2A> method of the <xref:Microsoft.Data.SqlClient.SqlDataReader> is called. For example, you cannot retrieve output parameters until after you call <xref:Microsoft.Data.SqlClient.SqlDataReader.Close%2A>.
|
||
|
|
||
|
Changes made to a result set by another process or thread while data is being read may be visible to the user of the `SqlDataReader`. However, the precise behavior is timing dependent.
|
||
|
|
||
|
<xref:Microsoft.Data.SqlClient.SqlDataReader.IsClosed%2A> and <xref:Microsoft.Data.SqlClient.SqlDataReader.RecordsAffected%2A> are the only properties that you can call after the <xref:Microsoft.Data.SqlClient.SqlDataReader> is closed. Although the <xref:Microsoft.Data.SqlClient.SqlDataReader.RecordsAffected%2A> property may be accessed while the <xref:Microsoft.Data.SqlClient.SqlDataReader> exists, always call <xref:Microsoft.Data.SqlClient.SqlDataReader.Close%2A> before returning the value of <xref:Microsoft.Data.SqlClient.SqlDataReader.RecordsAffected%2A> to guarantee an accurate return value.
|
||
|
|
||
|
When using sequential access (<xref:System.Data.CommandBehavior.SequentialAccess?displayProperty=nameWithType>), an <xref:System.InvalidOperationException> will be raised if the <xref:Microsoft.Data.SqlClient.SqlDataReader> position is advanced and another read operation is attempted on the previous column.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> For optimal performance, <xref:Microsoft.Data.SqlClient.SqlDataReader> avoids creating unnecessary objects or making unnecessary copies of data. Therefore, multiple calls to methods such as <xref:Microsoft.Data.SqlClient.SqlDataReader.GetValue%2A> return a reference to the same object. Use caution if you are modifying the underlying value of the objects returned by methods such as <xref:Microsoft.Data.SqlClient.SqlDataReader.GetValue%2A>.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlConnection>, a <xref:Microsoft.Data.SqlClient.SqlCommand>, and a <xref:Microsoft.Data.SqlClient.SqlDataReader>. The example reads through the data, writing it out to the console window. The code then closes the <xref:Microsoft.Data.SqlClient.SqlDataReader>. The <xref:Microsoft.Data.SqlClient.SqlConnection> is closed automatically at the end of the `using` code block.
|
||
|
|
||
|
[!code-csharp[SqlDataReader_Read Example#1](~/../sqlclient/doc/samples/SqlDataReader_Read.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlDataReader.Connection">
|
||
|
<summary>Gets the <see cref="T:Microsoft.Data.SqlClient.SqlConnection" /> associated with the <see cref="T:Microsoft.Data.SqlClient.SqlDataReader" />.</summary><value>The <see cref="T:Microsoft.Data.SqlClient.SqlConnection" /> associated with the <see cref="T:Microsoft.Data.SqlClient.SqlDataReader" />.</value><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlDataReader.Depth">
|
||
|
<summary>Gets a value that indicates the depth of nesting for the current row.</summary><value>The depth of nesting for the current row.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The outermost table has a depth of zero. The .NET Framework Data Provider for SQL Server does not support nesting and always returns zero.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlDataReader.FieldCount">
|
||
|
<summary>Gets the number of columns in the current row.</summary><value>When not positioned in a valid recordset, 0; otherwise the number of columns in the current row. The default is -1.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Executing a query that, by its nature, does not return rows (such as a DELETE query), sets <xref:Microsoft.Data.SqlClient.SqlDataReader.FieldCount%2A> to 0. However. this should not be confused with a query that returns 0 rows (such as SELECT * FROM *table* WHERE 1 = 2) in which case <xref:Microsoft.Data.SqlClient.SqlDataReader.FieldCount%2A> returns the number of columns in the table, including hidden fields. Use <xref:Microsoft.Data.SqlClient.SqlDataReader.VisibleFieldCount%2A> to exclude hidden fields.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.NotSupportedException">There is no current connection to an instance of SQL Server.</exception>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlDataReader.HasRows">
|
||
|
<summary>Gets a value that indicates whether the <see cref="T:Microsoft.Data.SqlClient.SqlDataReader" /> contains one or more rows.</summary><value>
|
||
|
<see langword="true" /> if the <see cref="T:Microsoft.Data.SqlClient.SqlDataReader" /> contains one or more rows; otherwise <see langword="false" />.</value><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlDataReader.IsClosed">
|
||
|
<summary>Retrieves a Boolean value that indicates whether the specified <see cref="T:Microsoft.Data.SqlClient.SqlDataReader" /> instance has been closed.</summary><value>
|
||
|
<see langword="true" /> if the specified <see cref="T:Microsoft.Data.SqlClient.SqlDataReader" /> instance is closed; otherwise <see langword="false" />.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
It is not possible to read from a <xref:Microsoft.Data.SqlClient.SqlDataReader> instance that is closed.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlDataReader.Item(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Gets the value of the specified column in its native format given the column ordinal.</summary><value>The value of the specified column in its native format.</value><remarks>To be added.</remarks><exception cref="T:System.IndexOutOfRangeException">The index passed was outside the range of 0 through <see cref="P:System.Data.IDataRecord.FieldCount" />.</exception>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlDataReader.Item(System.String)">
|
||
|
<param name="name">The column name.</param><summary>Gets the value of the specified column in its native format given the column name.</summary><value>The value of the specified column in its native format.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
A case-sensitive lookup is performed first. If it fails, a second case-insensitive search is made (a case-insensitive comparison is done using the database collation). Unexpected results can occur when comparisons are affected by culture-specific casing rules. For example, in Turkish, the following example yields the wrong results because the file system in Turkish does not use linguistic casing rules for the letter 'i' in "file".
|
||
|
|
||
|
This method is kana-width insensitive.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.IndexOutOfRangeException">No column with the specified name was found.</exception>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlDataReader.RecordsAffected">
|
||
|
<summary>Gets the number of rows changed, inserted, or deleted by execution of the Transact-SQL statement.</summary><value>The number of rows changed, inserted, or deleted; 0 if no rows were affected or the statement failed; and -1 for SELECT statements.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The value of this property is cumulative. For example, if two records are inserted in batch mode, the value of `RecordsAffected` will be two.
|
||
|
|
||
|
<xref:Microsoft.Data.SqlClient.SqlDataReader.IsClosed%2A> and <xref:Microsoft.Data.SqlClient.SqlDataReader.RecordsAffected%2A> are the only properties that you can call after the <xref:Microsoft.Data.SqlClient.SqlDataReader> is closed.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlDataReader.SensitivityClassification">
|
||
|
<summary>Gets the <see cref="T:Microsoft.Data.SqlClient.DataClassification.SensitivityClassification" /> information with the <see cref="T:Microsoft.Data.SqlClient.SqlDataReader" />.</summary><value>The <see cref="T:Microsoft.Data.SqlClient.DataClassification.SensitivityClassification" /> associated with the <see cref="T:Microsoft.Data.SqlClient.SqlDataReader" />.</value><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlDataReader.VisibleFieldCount">
|
||
|
<summary>Gets the number of fields in the <see cref="T:Microsoft.Data.SqlClient.SqlDataReader" /> that are not hidden.</summary><value>The number of fields that are not hidden.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This value is used to determine how many fields in the <xref:Microsoft.Data.SqlClient.SqlDataReader> are visible. For example, a SELECT on a partial primary key returns the remaining parts of the key as hidden fields. The hidden fields are always appended behind the visible fields.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.Close">
|
||
|
<summary>Closes the <see cref="T:Microsoft.Data.SqlClient.SqlDataReader" /> object.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
You must ensure the <xref:Microsoft.Data.SqlClient.SqlDataReader.Close%2A> method is called when you are through using the <xref:Microsoft.Data.SqlClient.SqlDataReader> before using the associated <xref:Microsoft.Data.SqlClient.SqlConnection> for any other purpose. The `Close` method may either be called directly or through the `Dispose` method, disposing directly or in the context of [the using statement](/dotnet/csharp/language-reference/language-specification/statements#the-using-statement) block.
|
||
|
|
||
|
The `Close` method populates the values for output parameters, return values and `RecordsAffected` on the <xref:Microsoft.Data.SqlClient.SqlDataReader> by consuming any pending results. This may be a long operation depending on the amount of data to be consumed. If output values, return values, and `RecordsAffected` are not important to your application, the time to close may be shortened by calling the <xref:Microsoft.Data.SqlClient.SqlCommand.Cancel%2A> method of the associated <xref:Microsoft.Data.SqlClient.SqlCommand> object before the `Close` method is called.
|
||
|
|
||
|
> [!CAUTION]
|
||
|
> Do not call `Close` or `Dispose` on a Connection, a DataReader, or any other managed object in the `Finalize` method of your class. In a finalizer, you should only release unmanaged resources that your class owns directly. If your class does not own any unmanaged resources, do not include a `Finalize` method in your class definition. For more information, see [Garbage Collection](/dotnet/standard/garbage-collection/).
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlConnection>, a <xref:Microsoft.Data.SqlClient.SqlCommand>, and a <xref:Microsoft.Data.SqlClient.SqlDataReader>. The example reads through the data, writing it out to the console window. The code then closes the <xref:Microsoft.Data.SqlClient.SqlDataReader>. The <xref:Microsoft.Data.SqlClient.SqlConnection> is closed automatically at the end of the `using` code block.
|
||
|
|
||
|
[!code-csharp[SqlDataReader_Close Example#1](~/../sqlclient/doc/samples/SqlDataReader_Close.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetBoolean(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Gets the value of the specified column as a Boolean.</summary><returns>The value of the column.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
No conversions are performed; therefore, the data retrieved must already be a Boolean, or an exception is generated.
|
||
|
|
||
|
Call <xref:Microsoft.Data.SqlClient.SqlDataReader.IsDBNull%2A> to check for null values before calling this method.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">The specified cast is not valid.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetByte(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Gets the value of the specified column as a byte.</summary><returns>The value of the specified column as a byte.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
No conversions are performed; therefore, the data retrieved must already be a byte.
|
||
|
|
||
|
Call <xref:Microsoft.Data.SqlClient.SqlDataReader.IsDBNull%2A> to check for null values before calling this method.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">The specified cast is not valid.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetBytes(System.Int32,System.Int64,System.Byte[],System.Int32,System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><param name="dataIndex">The index within the field from which to begin the read operation.</param><param name="buffer">The buffer into which to read the stream of bytes.</param><param name="bufferIndex">The index within the <paramref name="buffer" /> where the write operation is to start.</param><param name="length">The maximum length to copy into the buffer.</param><summary>Reads a stream of bytes from the specified column offset into the buffer an array starting at the given buffer offset.</summary><returns>The actual number of bytes read.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
<xref:Microsoft.Data.SqlClient.SqlDataReader.GetBytes%2A> returns the number of available bytes in the field. Most of the time this is the exact length of the field. However, the number returned may be less than the true length of the field if `GetBytes` has already been used to obtain bytes from the field. This may be the case, for example, if the <xref:Microsoft.Data.SqlClient.SqlDataReader> is reading a large data structure into a buffer. For more information, see the `SequentialAccess` setting for <xref:System.Data.CommandBehavior>.
|
||
|
|
||
|
If you pass a buffer that is `null`, <xref:Microsoft.Data.SqlClient.SqlDataReader.GetBytes%2A> returns the length of the entire field in bytes, not the remaining size based on the buffer offset parameter.
|
||
|
|
||
|
No conversions are performed; therefore, the data retrieved must already be a byte array.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetChar(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Gets the value of the specified column as a single character.</summary><returns>The value of the specified column.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Not supported for <xref:Microsoft.Data.SqlClient>.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">The specified cast is not valid.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetChars(System.Int32,System.Int64,System.Char[],System.Int32,System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><param name="dataIndex">The index within the field from which to begin the read operation.</param><param name="buffer">The buffer into which to read the stream of bytes.</param><param name="bufferIndex">The index within the <paramref name="buffer" /> where the write operation is to start.</param><param name="length">The maximum length to copy into the buffer.</param><summary>Reads a stream of characters from the specified column offset into the buffer as an array starting at the given buffer offset.</summary><returns>The actual number of characters read.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
<xref:Microsoft.Data.SqlClient.SqlDataReader.GetChars%2A> returns the number of available characters in the field. Frequently this is the exact length of the field. However, the number returned may be less than the true length of the field if `GetChars` has already been used to obtain characters from the field. This may be the case, for example, if the <xref:Microsoft.Data.SqlClient.SqlDataReader> is reading a large data structure into a buffer. For more information, see the `SequentialAccess` setting for <xref:System.Data.CommandBehavior>.
|
||
|
|
||
|
The actual number of characters read can be less than the requested length, if the end of the field is reached. If you pass a buffer that is `null`, <xref:Microsoft.Data.SqlClient.SqlDataReader.GetChars%2A> returns the length of the entire field in characters, not the remaining size based on the buffer offset parameter.
|
||
|
|
||
|
No conversions are performed; therefore. the data retrieved must already be a character array.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> The <xref:Microsoft.Data.SqlClient.SqlDataReader.GetChars%2A> method returns 0 when `dataIndex` is negative.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetColumnSchema">
|
||
|
<summary>Gets the read-only column schema collection.</summary><returns>The read-only column schema collection).</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
|
||
|
This method is an implementation of <xref:System.Data.Common.IDbColumnSchemaGenerator.GetColumnSchema?displayProperty=nameWithType> method, which enables the use of the <xref:System.Data.Common.IDbColumnSchemaGenerator> interface to populate the <xref:System.Data.Common.DbColumn> schema metadata without using a <xref:System.Data.DataTable>.
|
||
|
|
||
|
]]>
|
||
|
</format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetDataTypeName(System.Int32)">
|
||
|
<param name="i">The zero-based ordinal position of the column to find.</param><summary>Gets a string representing the data type of the specified column.</summary><returns>The string representing the data type of the specified column.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Returns the name of the back-end data type.
|
||
|
|
||
|
`numeric` is a synonym in SQL Server for the `decimal` data type. `GetDataTypeName` will return "decimal" for a column defined as either decimal or numeric.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetDateTime(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Gets the value of the specified column as a <see cref="T:System.DateTime" /> object.</summary><returns>The value of the specified column.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
No conversions are performed; therefore, the data retrieved must already be a <xref:System.DateTime> object.
|
||
|
|
||
|
Call <xref:Microsoft.Data.SqlClient.SqlDataReader.IsDBNull%2A> to check for null values before calling this method.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">The specified cast is not valid.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetDateTimeOffset(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Retrieves the value of the specified column as a <see cref="T:System.DateTimeOffset" /> object.</summary><returns>The value of the specified column.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
No conversions are performed; therefore, the data retrieved must already be a <xref:System.DateTimeOffset> object.
|
||
|
|
||
|
Call <xref:Microsoft.Data.SqlClient.SqlDataReader.IsDBNull%2A> to check for null values before calling this method.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">The specified cast is not valid.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetDecimal(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Gets the value of the specified column as a <see cref="T:System.Decimal" /> object.</summary><returns>The value of the specified column.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
No conversions are performed; therefore, the data retrieved must already be a <xref:System.Decimal> object.
|
||
|
|
||
|
Call <xref:Microsoft.Data.SqlClient.SqlDataReader.IsDBNull%2A> to check for null values before calling this method.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">The specified cast is not valid.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetDouble(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Gets the value of the specified column as a double-precision floating point number.</summary><returns>The value of the specified column.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
No conversions are performed. Therefore, the data retrieved must already be a double-precision floating point number.
|
||
|
|
||
|
Call <xref:Microsoft.Data.SqlClient.SqlDataReader.IsDBNull%2A> to check for null values before calling this method.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">The specified cast is not valid.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetEnumerator">
|
||
|
<summary>Returns an <see cref="T:System.Collections.IEnumerator" /> that iterates through the <see cref="T:Microsoft.Data.SqlClient.SqlDataReader" />.</summary><returns>An <see cref="T:System.Collections.IEnumerator" /> for the <see cref="T:Microsoft.Data.SqlClient.SqlDataReader" />.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Although you can use this method to retrieve an explicit enumerator, in languages that support a `foreach` construct, it is simpler to use the looping construct directly in order to iterate through the rows in the data reader.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetFieldType(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Gets the <see cref="T:System.Type" /> that is the data type of the object.</summary><returns>The <see cref="T:System.Type" /> that is the data type of the object. If the type does not exist on the client, in the case of a User-Defined Type (UDT) returned from the database, **GetFieldType** returns null.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetFieldValue``1(System.Int32)">
|
||
|
<typeparam name="T">The type of the value to be returned.</typeparam><param name="i">The column to be retrieved.</param><summary>Synchronously gets the value of the specified column as a type. <see cref="M:Microsoft.Data.SqlClient.SqlDataReader.GetFieldValueAsync``1(System.Int32,System.Threading.CancellationToken)" /> is the asynchronous version of this method.</summary><returns>The returned type object.</returns><remarks>
|
||
|
<format type="text/markdown">
|
||
|
<![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
`T` can be one of the following types:
|
||
|
|
||
|
|||||
|
||
|
|-|-|-|-|
|
||
|
|Boolean|Byte|Char|DateOnly (.NET 6 or later)|
|
||
|
|DateTime|DateTimeOffset|Decimal|Double|
|
||
|
|Float|Guid|Int16|Int32|
|
||
|
|Int64|SqlBoolean|SqlByte|SqlDateTime|
|
||
|
|SqlDecimal|SqlDouble|SqlGuid|SqlInt16|
|
||
|
|SqlInt32|SqlInt64|SqlMoney|SqlSingle|
|
||
|
|SqlString|Stream|String|TextReader|
|
||
|
|TimeOnly (.NET 6 or later)|XmlReader||UDT, which can be any CLR type marked with <xref:Microsoft.Data.SqlClient.Server.SqlUserDefinedTypeAttribute>.|
|
||
|
|
||
|
For more information, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidOperationException">The connection drops or is closed during the data retrieval.
|
||
|
|
||
|
The <see cref="T:Microsoft.Data.SqlClient.SqlDataReader" /> is closed during the data retrieval.
|
||
|
|
||
|
There is no data ready to be read (for example, the first <see cref="M:Microsoft.Data.SqlClient.SqlDataReader.Read" /> hasn't been called, or returned false).
|
||
|
|
||
|
Tried to read a previously-read column in sequential mode.
|
||
|
|
||
|
There was an asynchronous operation in progress. This applies to all Get* methods when running in sequential mode, as they could be called while reading a stream.</exception><exception cref="T:System.IndexOutOfRangeException">Trying to read a column that does not exist.</exception><exception cref="T:System.Data.SqlTypes.SqlNullValueException">The value of the column was null (<see cref="M:Microsoft.Data.SqlClient.SqlDataReader.IsDBNull(System.Int32)" /> == <see langword="true" />), retrieving a non-SQL type.</exception><exception cref="T:System.InvalidCastException">
|
||
|
<typeparamref name="T" /> doesn't match the type returned by SQL Server or cannot be cast.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetFieldValueAsync``1(System.Int32,System.Threading.CancellationToken)">
|
||
|
<typeparam name="T">The type of the value to be returned.</typeparam><param name="i">The column to be retrieved.</param><param name="cancellationToken">The cancellation instruction, which propagates a notification that operations should be canceled. This does not guarantee the cancellation. A setting of <see langword="CancellationToken.None" /> makes this method equivalent to <see cref="M:Microsoft.Data.SqlClient.SqlDataReader.IsDBNull(System.Int32)" />. The returned task must be marked as cancelled.</param><summary>Asynchronously gets the value of the specified column as a type. <see cref="M:Microsoft.Data.SqlClient.SqlDataReader.GetFieldValue``1(System.Int32)" /> is the synchronous version of this method.</summary><returns>The returned type object.</returns><remarks>
|
||
|
<format type="text/markdown">
|
||
|
<![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
`T` can be one of the following types:
|
||
|
|
||
|
|||||
|
||
|
|-|-|-|-|
|
||
|
|Boolean|Byte|Char|DateOnly (.NET 6 or later)|
|
||
|
|DateTime|DateTimeOffset|Decimal|Double|
|
||
|
|Float|Guid|Int16|Int32|
|
||
|
|Int64|SqlBoolean|SqlByte|SqlDateTime|
|
||
|
|SqlDecimal|SqlDouble|SqlGuid|SqlInt16|
|
||
|
|SqlInt32|SqlInt64|SqlMoney|SqlSingle|
|
||
|
|SqlString|Stream|String|TextReader|
|
||
|
|TimeOnly (.NET 6 or later)|XmlReader||UDT, which can be any CLR type marked with <xref:Microsoft.Data.SqlClient.Server.SqlUserDefinedTypeAttribute>.|
|
||
|
|
||
|
For more information, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidOperationException">The connection drops or is closed during the data retrieval.
|
||
|
|
||
|
The <see cref="T:Microsoft.Data.SqlClient.SqlDataReader" /> is closed during the data retrieval.
|
||
|
|
||
|
There is no data ready to be read (for example, the first <see cref="M:Microsoft.Data.SqlClient.SqlDataReader.Read" /> hasn't been called, or returned false).
|
||
|
|
||
|
Tried to read a previously-read column in sequential mode.
|
||
|
|
||
|
There was an asynchronous operation in progress. This applies to all Get* methods when running in sequential mode, as they could be called while reading a stream.</exception><exception cref="T:System.IndexOutOfRangeException">Trying to read a column that does not exist.</exception><exception cref="T:System.Data.SqlTypes.SqlNullValueException">The value of the column was null (<see cref="M:Microsoft.Data.SqlClient.SqlDataReader.IsDBNull(System.Int32)" /> == <see langword="true" />), retrieving a non-SQL type.</exception><exception cref="T:System.InvalidCastException">
|
||
|
<typeparamref name="T" /> doesn't match the type returned by SQL Server or cannot be cast.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetFloat(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Gets the value of the specified column as a single-precision floating point number.</summary><returns>The value of the specified column.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
No conversions are performed. Therefore, the data retrieved must already be a single-precision floating point number.
|
||
|
|
||
|
Call <xref:Microsoft.Data.SqlClient.SqlDataReader.IsDBNull%2A> to check for null values before calling this method.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">The specified cast is not valid.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetGuid(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Gets the value of the specified column as a globally unique identifier (GUID).</summary><returns>The value of the specified column.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
No conversions are performed; therefore, the data retrieved must already be a GUID.
|
||
|
|
||
|
Call <xref:Microsoft.Data.SqlClient.SqlDataReader.IsDBNull%2A> to check for null values before calling this method.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">The specified cast is not valid.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetInt16(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Gets the value of the specified column as a 16-bit signed integer.</summary><returns>The value of the specified column.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
No conversions are performed; therefore, the data retrieved must already be a 16-bit signed integer.
|
||
|
|
||
|
Call <xref:Microsoft.Data.SqlClient.SqlDataReader.IsDBNull%2A> to check for null values before calling this method.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">The specified cast is not valid.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetInt32(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Gets the value of the specified column as a 32-bit signed integer.</summary><returns>The value of the specified column.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
No conversions are performed; therefore, the data retrieved must already be a 32-bit signed integer.
|
||
|
|
||
|
Call <xref:Microsoft.Data.SqlClient.SqlDataReader.IsDBNull%2A> to check for null values before calling this method.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">The specified cast is not valid.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetInt64(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Gets the value of the specified column as a 64-bit signed integer.</summary><returns>The value of the specified column.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
No conversions are performed; therefore, the data retrieved must already be a 64-bit signed integer.
|
||
|
|
||
|
Call <xref:Microsoft.Data.SqlClient.SqlDataReader.IsDBNull%2A> to check for null values before calling this method.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">The specified cast is not valid.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetName(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Gets the name of the specified column.</summary><returns>The name of the specified column.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetOrdinal(System.String)">
|
||
|
<param name="name">The name of the column.</param><summary>Gets the column ordinal, given the name of the column.</summary><returns>The zero-based column ordinal.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
`GetOrdinal` performs a case-sensitive lookup first. If it fails, a second, case-insensitive search occurs (a case-insensitive comparison is done using the database collation). Unexpected results can occur when comparisons are affected by culture-specific casing rules. For example, in Turkish, the following example yields the wrong results because the file system in Turkish does not use linguistic casing rules for the letter 'i' in "file". The method throws an `IndexOutOfRange` exception if the zero-based column ordinal is not found.
|
||
|
|
||
|
`GetOrdinal` is kana-width insensitive.
|
||
|
|
||
|
Because ordinal-based lookups are more efficient than named lookups, it is inefficient to call `GetOrdinal` within a loop. Save time by calling `GetOrdinal` once and assigning the results to an integer variable for use within the loop.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example demonstrates how to use the <xref:Microsoft.Data.SqlClient.SqlDataReader.GetOrdinal%2A> method.
|
||
|
|
||
|
[!code-csharp[SqlDataReader_GetOrdinal#1](~/../sqlclient/doc/samples/SqlDataReader_GetOrdinal.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.IndexOutOfRangeException">The name specified is not a valid column name.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetProviderSpecificFieldType(System.Int32)">
|
||
|
<param name="i">An <see cref="T:System.Int32" /> representing the column ordinal.</param><summary>Gets an <see langword="Object" /> that is a representation of the underlying provider-specific field type.</summary><returns>Gets an <see cref="T:System.Object" /> that is a representation of the underlying provider-specific field type.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetProviderSpecificValue(System.Int32)">
|
||
|
<param name="i">An <see cref="T:System.Int32" /> representing the column ordinal.</param><summary>Gets an <see langword="Object" /> that is a representation of the underlying provider specific value.</summary><returns>An <see cref="T:System.Object" /> that is a representation of the underlying provider specific value.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetProviderSpecificValues(System.Object[])">
|
||
|
<param name="values">An array of <see cref="T:System.Object" /> into which to copy the column values.</param><summary>Gets an array of objects that are a representation of the underlying provider specific values.</summary><returns>The array of objects that are a representation of the underlying provider specific values.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetSqlBinary(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Gets the value of the specified column as a <see cref="T:System.Data.SqlTypes.SqlBinary" />.</summary><returns>The value of the column expressed as a <see cref="T:System.Data.SqlTypes.SqlBinary" />.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
No conversions are performed; therefore the data retrieved must already be a binary structure or an exception is generated.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetSqlBoolean(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Gets the value of the specified column as a <see cref="T:System.Data.SqlTypes.SqlBoolean" />.</summary><returns>The value of the column.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
No conversions are performed; therefore, the data retrieved must already be a Boolean or an exception is generated.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetSqlByte(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Gets the value of the specified column as a <see cref="T:System.Data.SqlTypes.SqlByte" />.</summary><returns>The value of the column expressed as a <see cref="T:System.Data.SqlTypes.SqlByte" />.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
No conversions are performed; therefore the data retrieved must already be a byte, or an exception is generated.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetSqlBytes(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Gets the value of the specified column as <see cref="T:System.Data.SqlTypes.SqlBytes" />.</summary><returns>The value of the column expressed as a <see cref="T:System.Data.SqlTypes.SqlBytes" />.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetSqlChars(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Gets the value of the specified column as <see cref="T:System.Data.SqlTypes.SqlChars" />.</summary><returns>The value of the column expressed as a <see cref="T:System.Data.SqlTypes.SqlChars" />.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetSqlDateTime(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Gets the value of the specified column as a <see cref="T:System.Data.SqlTypes.SqlDateTime" />.</summary><returns>The value of the column expressed as a <see cref="T:System.Data.SqlTypes.SqlDateTime" />.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
No conversions are performed; therefore, the data retrieved must already be a date/time value, or an exception is generated.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetSqlDecimal(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Gets the value of the specified column as a <see cref="T:System.Data.SqlTypes.SqlDecimal" />.</summary><returns>The value of the column expressed as a <see cref="T:System.Data.SqlTypes.SqlDecimal" />.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
No conversions are performed; therefore, the data retrieved must already be a decimal value, or an exception is generated.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetSqlDouble(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Gets the value of the specified column as a <see cref="T:System.Data.SqlTypes.SqlDouble" />.</summary><returns>The value of the column expressed as a <see cref="T:System.Data.SqlTypes.SqlDouble" />.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
No conversions are performed; therefore, the data retrieved must already be a double-precision floating-point number, or an exception is generated.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetSqlGuid(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Gets the value of the specified column as a <see cref="T:System.Data.SqlTypes.SqlGuid" />.</summary><returns>The value of the column expressed as a <see cref="T:System.Data.SqlTypes.SqlGuid" />.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
No conversions are performed; therefore, the data retrieved must already be a GUID, or an exception is generated.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetSqlInt16(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Gets the value of the specified column as a <see cref="T:System.Data.SqlTypes.SqlInt16" />.</summary><returns>The value of the column expressed as a <see cref="T:System.Data.SqlTypes.SqlInt16" />.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
No conversions are performed; therefore, the data retrieved must already be a 16-bit signed integer, or an exception is generated.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetSqlInt32(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Gets the value of the specified column as a <see cref="T:System.Data.SqlTypes.SqlInt32" />.</summary><returns>The value of the column expressed as a <see cref="T:System.Data.SqlTypes.SqlInt32" />.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
No conversions are performed; therefore the data retrieved must already be a 32-bit signed integer, or an exception is generated.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetSqlInt64(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Gets the value of the specified column as a <see cref="T:System.Data.SqlTypes.SqlInt64" />.</summary><returns>The value of the column expressed as a <see cref="T:System.Data.SqlTypes.SqlInt64" />.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
No conversions are performed; therefore, the data retrieved must already be a 64-bit signed integer, or an exception is generated.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetSqlMoney(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Gets the value of the specified column as a <see cref="T:System.Data.SqlTypes.SqlMoney" />.</summary><returns>The value of the column expressed as a <see cref="T:System.Data.SqlTypes.SqlMoney" />.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
No conversions are performed; therefore, the data retrieved must already be a decimal value, or an exception is generated.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetSqlSingle(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Gets the value of the specified column as a <see cref="T:System.Data.SqlTypes.SqlSingle" />.</summary><returns>The value of the column expressed as a <see cref="T:System.Data.SqlTypes.SqlSingle" />.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
No conversions are performed; therefore, the data retrieved must already be a single precision floating point number, or an exception is generated.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetSqlString(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Gets the value of the specified column as a <see cref="T:System.Data.SqlTypes.SqlString" />.</summary><returns>The value of the column expressed as a <see cref="T:System.Data.SqlTypes.SqlString" />.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
No conversions are performed; therefore, the data retrieved must already be a string, or an exception is generated.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetSqlValue(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Returns the data value in the specified column as a SQL Server type.</summary><returns>The value of the column expressed as a <see cref="T:System.Data.SqlDbType" />.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
<xref:Microsoft.Data.SqlClient.SqlDataReader.GetSqlValue%2A> returns data using the native SQL Server types. To retrieve data using the .NET Framework types, see <xref:Microsoft.Data.SqlClient.SqlDataReader.GetValue%2A>.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetSqlValues(System.Object[])">
|
||
|
<param name="values">An array of <see cref="T:System.Object" /> into which to copy the values. The column values are expressed as SQL Server types.</param><summary>Fills an array of <see cref="T:System.Object" /> that contains the values for all the columns in the record, expressed as SQL Server types.</summary><returns>An integer indicating the number of columns copied.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Returns the values for all the columns in the record in a single call, using the SQL type system instead of the CLR type system. The length of the <xref:System.Object> array does not need to match the number of columns in the record. You can pass an <xref:System.Object> array that contains fewer than the number of columns contained in the record. Only the amount of data the <xref:System.Object> array holds is copied to the array, starting at the column with ordinal 0. You can also pass an <xref:System.Object> array whose length is more than the number of columns contained in the resulting row. Any remaining columns are untouched.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">
|
||
|
<paramref name="values" /> is null.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetSqlXml(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Gets the value of the specified column as an XML value.</summary><returns>A <see cref="T:System.Data.SqlTypes.SqlXml" /> value that contains the XML stored within the corresponding field.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
No conversions are performed; therefore, the data retrieved must already be an XML value.
|
||
|
|
||
|
Call <xref:Microsoft.Data.SqlClient.SqlDataReader.IsDBNull%2A> to check for null values before calling this method.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentOutOfRangeException">The index passed was outside the range of 0 to <see cref="P:System.Data.DataTableReader.FieldCount" /> - 1</exception><exception cref="T:System.InvalidOperationException">An attempt was made to read or access columns in a closed <see cref="T:Microsoft.Data.SqlClient.SqlDataReader" />.</exception><exception cref="T:System.InvalidCastException">The retrieved data is not compatible with the <see cref="T:System.Data.SqlTypes.SqlXml" /> type.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetSchemaTable">
|
||
|
<summary>Returns a <see cref="T:System.Data.DataTable" /> that describes the column metadata of the <see cref="T:Microsoft.Data.SqlClient.SqlDataReader" />.</summary><returns>A <see cref="T:System.Data.DataTable" /> that describes the column metadata.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlDataReader.GetSchemaTable%2A> method returns the following metadata about each column:
|
||
|
|
||
|
|DataReader column|Description|
|
||
|
|-----------------------|-----------------|
|
||
|
|AllowDBNull|Set if the consumer can set the column to a null value or if the provider cannot determine whether the consumer can set the column to a null value. Otherwise, not set. A column may contain null values, even if it cannot be set to a null value.|
|
||
|
|BaseCatalogName|The name of the catalog in the data store that contains the column. NULL if the base catalog name cannot be determined. The default of this column is a null value.|
|
||
|
|BaseColumnName|The name of the column in the data store. This might be different than the column name returned in the ColumnName column if an alias was used. A null value if the base column name cannot be determined or if the rowset column is derived, but not identical to, a column in the data store. The default of this column is a null value.|
|
||
|
|BaseSchemaName|The name of the schema in the data store that contains the column. A null value if the base schema name cannot be determined. The default of this column is a null value.|
|
||
|
|BaseServerName|The name of the instance of Microsoft SQL Server used by the <xref:Microsoft.Data.SqlClient.SqlDataReader>.|
|
||
|
|BaseTableName|The name of the table or view in the data store that contains the column. A null value if the base table name cannot be determined. The default of this column is a null value.|
|
||
|
|ColumnName|The name of the column; this might not be unique. If this cannot be determined, a null value is returned. This name always reflects the most recent renaming of the column in the current view or command text.|
|
||
|
|ColumnOrdinal|The zero-based ordinal of the column. This column cannot contain a null value.|
|
||
|
|ColumnSize|The maximum possible length of a value in the column. For columns that use a fixed-length data type, this is the size of the data type. For `nvarchar(MAX)`, `varchar(MAX)`, and `varbinary(MAX)` columns stored in a SQL Server database, the maximum size is 2GB. If these columns are stored and accessed as files, the limit on maximum size is imposed by the file system. This value changes when using the `Type System Version` keyword in the connection string. For new types they are represented as downlevel types. The MAX data types return the normal 4k for `nvarchar` and 8000 for `varchar`. For more information, see the [Transact-SQL reference](/sql/t-sql/language-reference).|
|
||
|
|DataTypeName|Returns a string representing the data type of the specified column.|
|
||
|
|IsAliased|`true`: The column name is an alias.<br /><br /> `false`: The column name is not an alias.|
|
||
|
|IsAutoIncrement|`true`: The column assigns values to new rows in fixed increments.<br /><br /> `false`: The column does not assign values to new rows in fixed increments. The default of this column is `false`.|
|
||
|
|IsColumnSet|`true`: The column is a sparse column that is a member of a column set.|
|
||
|
|IsExpression|`true`: The column is an expression.<br /><br /> `false`: The column is not an expression.|
|
||
|
|IsHidden|`true`: The column is hidden.<br /><br /> `false`: The column is not hidden.|
|
||
|
|IsIdentity|`true`: The column is an identity column.<br /><br /> `false`: The column is not an identity column.|
|
||
|
|IsKey|`true`: The column is one of a set of columns in the rowset that, taken together, uniquely identify the row. The set of columns with `IsKey` set to `true` must uniquely identify a row in the rowset. There is no requirement that this set of columns is a minimal set of columns. This set of columns may be generated from a base table primary key, a unique constraint or a unique index.<br /><br /> `false`: The column is not required to uniquely identify the row.|
|
||
|
|IsLong|`true`: The column contains a Binary Long Object (BLOB) that contains very long data. The definition of very long data is provider-specific.<br /><br /> `false`: The column does not contain a Binary Long Object (BLOB) that contains very long data.|
|
||
|
|IsReadOnly|`true`: The column cannot be modified.<br /><br /> `false`: The column can be modified.|
|
||
|
|IsRowVersion|`true`: The column contains a persistent row identifier that cannot be written to, and has no meaningful value except to identity the row.<br /><br /> `false`: The column does not contain a persistent row identifier that cannot be written to, and has no meaningful value except to identity the row.|
|
||
|
|IsUnique|`true`: Column is of type `timestamp`.<br /><br /> `false`: Column is not of type `timestamp`.|
|
||
|
|NonVersionedProviderType|The type of the column irrespective of the current `Type System Version` specified in the connection string. The returned value is from the <xref:System.Data.SqlDbType> enumeration.|
|
||
|
|NumericPrecision|If `ProviderType` is a numeric data type, this is the maximum precision of the column. The precision depends on the definition of the column. If `ProviderType` is not a numeric data type, this is 255.|
|
||
|
|NumericScale|If `ProviderType` is DBTYPE_DECIMAL or DBTYPE_NUMERIC, the number of digits to the right of the decimal point. Otherwise, this is 255.|
|
||
|
|ProviderSpecificDataType|Returns the provider-specific data type of the column based on the `Type System Version` keyword in the connection string.|
|
||
|
|ProviderType|The indicator of the column's data type. If the data type of the column varies from row to row, this must be Object. This column cannot contain a null value.|
|
||
|
|UdtAssemblyQualifiedName|If the column is a user-defined type (UDT), this is the qualified name of the UDT's assembly as per <xref:System.Type.AssemblyQualifiedName%2A>. If the column is not a UDT, this is null.|
|
||
|
|XmlSchemaCollectionDatabase|The name of the database where the schema collection for this XML instance is located, if the row contains information about an XML column. This value is `null` (`Nothing` in Visual Basic) if the collection is defined within the current database. It is also null if there is no schema collection, in which case the `XmlSchemaCollectionName` and `XmlSchemaCollectionOwningSchema` columns are also null.|
|
||
|
|XmlSchemaCollectionName|The name of the schema collection for this XML instance, if the row contains information about an XML column. This value is `null` (`Nothing` in Visual Basic) if there is no associated schema collection. If the value is null, the `XmlSchemaCollectionDatabase` and `XmlSchemaCollectionOwningSchema` columns are also null.|
|
||
|
|XmlSchemaCollectionOwningSchema|The owning relational schema where the schema collection for this XML instance is located, if the row contains information about an XML column. This value is `null` (`Nothing` in Visual Basic) if the collection is defined within the current database. It is also null if there is no schema collection, in which case the `XmlSchemaCollectionDatabase` and `XmlSchemaCollectionName` columns are also null.|
|
||
|
|
||
|
> [!NOTE]
|
||
|
> To make sure that metadata columns return the correct information, you must call <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteReader%2A> with the `behavior` parameter set to `KeyInfo`. Otherwise, some of the columns in the schema table may return default, null, or incorrect data.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidOperationException">The <see cref="T:Microsoft.Data.SqlClient.SqlDataReader" /> is closed.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetStream(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Retrieves binary, image, varbinary, UDT, and variant data types as a <see cref="T:System.IO.Stream" />.</summary><returns>A stream object.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
<xref:System.IO.Stream.ReadTimeout%2A> defaults to the value of <xref:Microsoft.Data.SqlClient.SqlCommand.CommandTimeout%2A>; but you can modify <xref:System.IO.Stream.ReadTimeout%2A> via <xref:Microsoft.Data.SqlClient.SqlDataReader.GetStream%2A>.
|
||
|
|
||
|
Null values will be returned as an empty (zero bytes) <xref:System.IO.Stream>.
|
||
|
|
||
|
<xref:Microsoft.Data.SqlClient.SqlDataReader.GetBytes%2A> will raise an <xref:System.InvalidOperationException> exception when used on an object returned by <xref:Microsoft.Data.SqlClient.SqlDataReader.GetStream%2A> when <xref:System.Data.CommandBehavior.SequentialAccess> is in effect.
|
||
|
|
||
|
<xref:Microsoft.Data.SqlClient.SqlException> exceptions raised from <xref:System.IO.Stream> are thrown as <xref:System.IO.IOException> exceptions; check the inner exception for the <xref:Microsoft.Data.SqlClient.SqlException>.
|
||
|
|
||
|
The following <xref:System.IO.Stream> members are not available for objects returned by <xref:Microsoft.Data.SqlClient.SqlDataReader.GetStream%2A>:
|
||
|
|
||
|
- BeginWrite
|
||
|
|
||
|
- EndWrite
|
||
|
|
||
|
- Length
|
||
|
|
||
|
- Position
|
||
|
|
||
|
- Seek
|
||
|
|
||
|
- SetLength
|
||
|
|
||
|
- Write
|
||
|
|
||
|
- WriteByte
|
||
|
|
||
|
- WriteTimeout
|
||
|
|
||
|
For more information, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidOperationException">The connection drops or is closed during the data retrieval.
|
||
|
|
||
|
The <see cref="T:Microsoft.Data.SqlClient.SqlDataReader" /> is closed during the data retrieval.
|
||
|
|
||
|
There is no data ready to be read (for example, the first <see cref="M:Microsoft.Data.SqlClient.SqlDataReader.Read" /> hasn't been called, or returned false).
|
||
|
|
||
|
Tried to read a previously-read column in sequential mode.
|
||
|
|
||
|
There was an asynchronous operation in progress. This applies to all Get* methods when running in sequential mode, as they could be called while reading a stream.</exception><exception cref="T:System.IndexOutOfRangeException">Trying to read a column that does not exist.</exception><exception cref="T:System.InvalidCastException">The returned type was not one of the types below:
|
||
|
|
||
|
- binary
|
||
|
|
||
|
- image
|
||
|
|
||
|
- varbinary
|
||
|
|
||
|
- udt</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetString(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Gets the value of the specified column as a string.</summary><returns>The value of the specified column.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
No conversions are performed; therefore, the data retrieved must already be a string.
|
||
|
|
||
|
Call <xref:Microsoft.Data.SqlClient.SqlDataReader.IsDBNull%2A> to check for null values before calling this method.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">The specified cast is not valid.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetTextReader(System.Int32)">
|
||
|
<param name="i">The column to be retrieved.</param><summary>Retrieves Char, NChar, NText, NVarChar, text, varChar, and Variant data types as a <see cref="T:System.IO.TextReader" />.</summary><returns>The returned object.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
<xref:Microsoft.Data.SqlClient.SqlException> exceptions raised from <xref:System.IO.TextReader> are thrown as <xref:System.IO.IOException> exceptions; check the inner exception for the <xref:Microsoft.Data.SqlClient.SqlException>.
|
||
|
|
||
|
Null values will be returned as an empty (zero bytes) <xref:System.IO.TextReader>.
|
||
|
|
||
|
<xref:Microsoft.Data.SqlClient.SqlDataReader.GetChars%2A> will raise an <xref:System.InvalidOperationException> exception when used on an object returned by <xref:Microsoft.Data.SqlClient.SqlDataReader.GetTextReader%2A> when <xref:System.Data.CommandBehavior.SequentialAccess> is in effect.
|
||
|
|
||
|
For more information, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidOperationException">The connection drops or is closed during the data retrieval.
|
||
|
|
||
|
The <see cref="T:Microsoft.Data.SqlClient.SqlDataReader" /> is closed during the data retrieval.
|
||
|
|
||
|
There is no data ready to be read (for example, the first <see cref="M:Microsoft.Data.SqlClient.SqlDataReader.Read" /> hasn't been called, or returned false).
|
||
|
|
||
|
Tried to read a previously-read column in sequential mode.
|
||
|
|
||
|
There was an asynchronous operation in progress. This applies to all Get* methods when running in sequential mode, as they could be called while reading a stream.</exception><exception cref="T:System.IndexOutOfRangeException">Trying to read a column that does not exist.</exception><exception cref="T:System.InvalidCastException">The returned type was not one of the types below:
|
||
|
|
||
|
- char
|
||
|
|
||
|
- nchar
|
||
|
|
||
|
- ntext
|
||
|
|
||
|
- nvarchar
|
||
|
|
||
|
- text
|
||
|
|
||
|
- varchar</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetTimeSpan(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Retrieves the value of the specified column as a <see cref="T:System.TimeSpan" /> object.</summary><returns>The value of the specified column.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
No conversions are performed; therefore, the data retrieved must already be a <xref:System.TimeSpan> object.
|
||
|
|
||
|
Call <xref:Microsoft.Data.SqlClient.SqlDataReader.IsDBNull%2A> to check for null values before calling this method.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">The specified cast is not valid.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetValue(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Gets the value of the specified column in its native format.</summary><returns>This method returns <see cref="T:System.DBNull" /> for null database columns.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
<xref:Microsoft.Data.SqlClient.SqlDataReader.GetValue%2A> returns data using the .NET Framework types.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetValues(System.Object[])">
|
||
|
<param name="values">An array of <see cref="T:System.Object" /> into which to copy the attribute columns.</param><summary>Populates an array of objects with the column values of the current row.</summary><returns>The number of instances of <see cref="T:System.Object" /> in the array.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
For most applications, this method provides an efficient means for retrieving all columns, instead of retrieving each column individually.
|
||
|
|
||
|
You can pass an <xref:System.Object> array that contains fewer than the number of columns contained in the resulting row. Only the amount of data the <xref:System.Object> array holds is copied to the array. You can also pass an <xref:System.Object> array whose length is more than the number of columns contained in the resulting row.
|
||
|
|
||
|
This method returns <xref:System.DBNull> for null database columns.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example demonstrates using a correctly sized array to read all values from the current row in the supplied <xref:Microsoft.Data.SqlClient.SqlDataReader>. In addition, the sample demonstrates using a fixed-sized array that could be either smaller or larger than the number of available columns.
|
||
|
|
||
|
[!code-csharp[DataTableReader_GetValues#2](~/../sqlclient/doc/samples/DataTableReader_GetValues.cs#2)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.GetXmlReader(System.Int32)">
|
||
|
<param name="i">The value of the specified column.</param><summary>Retrieves data of type XML as an <see cref="T:System.Xml.XmlReader" />.</summary><returns>The returned object.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:System.Xml.XmlReader> object returned by <xref:Microsoft.Data.SqlClient.SqlDataReader.GetXmlReader%2A> does not support asynchronous operations. If you require asynchronous operations on an <xref:System.Xml.XmlReader>, cast the XML column to an NVARCHAR(MAX) on the server and use <xref:Microsoft.Data.SqlClient.SqlDataReader.GetTextReader%2A> with <xref:System.Xml.XmlReader.Create%2A>.
|
||
|
|
||
|
<xref:Microsoft.Data.SqlClient.SqlException> exceptions raised from <xref:System.Xml.XmlReader> are thrown as <xref:System.Xml.XmlException> exceptions; check the inner exception for the <xref:Microsoft.Data.SqlClient.SqlException>.
|
||
|
|
||
|
<xref:Microsoft.Data.SqlClient.SqlDataReader.GetChars%2A> will raise an <xref:System.InvalidOperationException> exception when used on an object returned by <xref:Microsoft.Data.SqlClient.SqlDataReader.GetXmlReader%2A> when <xref:System.Data.CommandBehavior.SequentialAccess> is in effect.
|
||
|
|
||
|
For more information, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidOperationException">The connection drops or is closed during the data retrieval.
|
||
|
|
||
|
The <see cref="T:Microsoft.Data.SqlClient.SqlDataReader" /> is closed during the data retrieval.
|
||
|
|
||
|
There is no data ready to be read (for example, the first <see cref="M:Microsoft.Data.SqlClient.SqlDataReader.Read" /> hasn't been called, or returned false).
|
||
|
|
||
|
Trying to read a previously read column in sequential mode.
|
||
|
|
||
|
There was an asynchronous operation in progress. This applies to all Get* methods when running in sequential mode, as they could be called while reading a stream.</exception><exception cref="T:System.IndexOutOfRangeException">Trying to read a column that does not exist.</exception><exception cref="T:System.InvalidCastException">The returned type was not xml.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.IsCommandBehavior(System.Data.CommandBehavior)">
|
||
|
<param name="condition">A <see cref="T:System.Data.CommandBehavior" /> enumeration.</param><summary>Determines whether the specified <see cref="T:System.Data.CommandBehavior" /> matches that of the <see cref="T:Microsoft.Data.SqlClient.SqlDataReader" /> .</summary><returns>
|
||
|
<see langword="true" /> if the specified <see cref="T:System.Data.CommandBehavior" /> is true, <see langword="false" /> otherwise.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.IsDBNull(System.Int32)">
|
||
|
<param name="i">The zero-based column ordinal.</param><summary>Gets a value that indicates whether the column contains non-existent or missing values.</summary><returns>
|
||
|
<see langword="true" /> if the specified column value is equivalent to <see cref="T:System.DBNull" />; otherwise <see langword="false" />.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Call this method to check for null column values before calling the typed get methods (for example, <xref:Microsoft.Data.SqlClient.SqlDataReader.GetByte%2A>, <xref:Microsoft.Data.SqlClient.SqlDataReader.GetChar%2A>, and so on) to avoid raising an error.
|
||
|
|
||
|
[!code-csharp[SqlDataReader_IsDBNull#1](~/../sqlclient/doc/samples/SqlDataReader_IsDBNull.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.IsDBNullAsync(System.Int32,System.Threading.CancellationToken)">
|
||
|
<param name="i">The zero-based column to be retrieved.</param><param name="cancellationToken">The cancellation instruction, which propagates a notification that operations should be canceled. This does not guarantee the cancellation. A setting of <see langword="CancellationToken.None" /> makes this method equivalent to <see cref="M:Microsoft.Data.SqlClient.SqlDataReader.IsDBNull(System.Int32)" />. The returned task must be marked as cancelled.</param><summary>An asynchronous version of <see cref="M:Microsoft.Data.SqlClient.SqlDataReader.IsDBNull(System.Int32)" />, which gets a value that indicates whether the column contains non-existent or missing values.
|
||
|
|
||
|
The cancellation token can be used to request that the operation be abandoned before the command timeout elapses. Exceptions will be reported via the returned Task object.</summary><returns>
|
||
|
<see langword="true" /> if the specified column value is equivalent to <see langword="DBNull" /> otherwise <see langword="false" />.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
For more information, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidOperationException">The connection drops or is closed during the data retrieval.
|
||
|
|
||
|
The <see cref="T:Microsoft.Data.SqlClient.SqlDataReader" /> is closed during the data retrieval.
|
||
|
|
||
|
There is no data ready to be read (for example, the first <see cref="M:Microsoft.Data.SqlClient.SqlDataReader.Read" /> hasn't been called, or returned false).
|
||
|
|
||
|
Trying to read a previously read column in sequential mode.
|
||
|
|
||
|
There was an asynchronous operation in progress. This applies to all Get* methods when running in sequential mode, as they could be called while reading a stream.</exception><exception cref="T:System.IndexOutOfRangeException">Trying to read a column that does not exist.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.NextResult">
|
||
|
<summary>Advances the data reader to the next result, when reading the results of batch Transact-SQL statements.</summary><returns>
|
||
|
<see langword="true" /> if there are more result sets; otherwise <see langword="false" />.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Used to process multiple results, which can be generated by executing batch Transact-SQL statements.
|
||
|
|
||
|
By default, the data reader is positioned on the first result.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.NextResultAsync(System.Threading.CancellationToken)">
|
||
|
<param name="cancellationToken">The cancellation instruction.</param><summary>An asynchronous version of <see cref="M:Microsoft.Data.SqlClient.SqlDataReader.NextResult" />, which advances the data reader to the next result, when reading the results of batch Transact-SQL statements.
|
||
|
|
||
|
The cancellation token can be used to request that the operation be abandoned before the command timeout elapses. Exceptions will be reported via the returned Task object.</summary><returns>A task representing the asynchronous operation.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see [Asynchronous Programming](/sql/connect/ado-net/asynchronous-programming).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidOperationException">Calling <see cref="M:Microsoft.Data.SqlClient.SqlDataReader.NextResultAsync(System.Threading.CancellationToken)" /> more than once for the same instance before task completion.</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">SQL Server returned an error while executing the command text.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.Read">
|
||
|
<summary>Advances the <see cref="T:Microsoft.Data.SqlClient.SqlDataReader" /> to the next record.</summary><returns>
|
||
|
<see langword="true" /> if there are more rows; otherwise <see langword="false" />.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The default position of the <xref:Microsoft.Data.SqlClient.SqlDataReader> is before the first record. Therefore, you must call <xref:Microsoft.Data.SqlClient.SqlDataReader.Read%2A> to begin accessing any data.
|
||
|
|
||
|
Only one `SqlDataReader` per associated <xref:Microsoft.Data.SqlClient.SqlConnection> may be open at a time, and any attempt to open another will fail until the first one is closed. Similarly, while the `SqlDataReader` is being used, the associated `SqlConnection` is busy serving it until you call <xref:Microsoft.Data.SqlClient.SqlDataReader.Close%2A>.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlConnection>, a <xref:Microsoft.Data.SqlClient.SqlCommand>, and a <xref:Microsoft.Data.SqlClient.SqlDataReader>. The example reads through the data, writing it out to the console window. The code then closes the <xref:Microsoft.Data.SqlClient.SqlDataReader>. The <xref:Microsoft.Data.SqlClient.SqlConnection> is closed automatically at the end of the `using` code block.
|
||
|
|
||
|
[!code-csharp[SqlDataReader_Read Example#1](~/../sqlclient/doc/samples/SqlDataReader_Read.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:Microsoft.Data.SqlClient.SqlException">SQL Server returned an error while executing the command text.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDataReader.ReadAsync(System.Threading.CancellationToken)">
|
||
|
<param name="cancellationToken">The cancellation instruction.</param><summary>An asynchronous version of <see cref="M:Microsoft.Data.SqlClient.SqlDataReader.Read" />, which advances the <see cref="T:Microsoft.Data.SqlClient.SqlDataReader" /> to the next record.
|
||
|
|
||
|
The cancellation token can be used to request that the operation be abandoned before the command timeout elapses. Exceptions will be reported via the returned Task object.</summary><returns>A task representing the asynchronous operation.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
If the `behavior` parameter of <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteReaderAsync%2A> is set to `Default`, <xref:Microsoft.Data.SqlClient.SqlDataReader.ReadAsync%2A> reads the entire row before returning the Task.
|
||
|
|
||
|
For more information, including code samples, about asynchronous programming in the .NET Framework Data Provider for SQL Server, see [Asynchronous Programming](/sql/connect/ado-net/asynchronous-programming).
|
||
|
|
||
|
> [!NOTE]
|
||
|
> When reading large data (binary/text), it is recommended to use <xref:Microsoft.Data.SqlClient.SqlDataReader.Read%2A> for optimal performance.
|
||
|
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidOperationException">Calling <see cref="M:Microsoft.Data.SqlClient.SqlDataReader.ReadAsync(System.Threading.CancellationToken)" /> more than once for the same instance before task completion.</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">SQL Server returned an error while executing the command text.</exception>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlDependency">
|
||
|
<summary>The <see cref="T:Microsoft.Data.SqlClient.SqlDependency" /> object represents a query notification dependency between an application and an instance of SQL Server. An application can create a <see cref="T:Microsoft.Data.SqlClient.SqlDependency" /> object and register to receive notifications via the <see cref="T:Microsoft.Data.SqlClient.OnChangeEventHandler" /> event handler.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
<xref:Microsoft.Data.SqlClient.SqlDependency> is ideal for caching scenarios, where your ASP.NET application or middle-tier service needs to keep certain information cached in memory. <xref:Microsoft.Data.SqlClient.SqlDependency> allows you to receive notifications when the original data in the database changes so that the cache can be refreshed.
|
||
|
|
||
|
To set up a dependency, you need to associate a <xref:Microsoft.Data.SqlClient.SqlDependency> object to one or more <xref:Microsoft.Data.SqlClient.SqlCommand> objects. To receive notifications, you need to subscribe to the <xref:Microsoft.Data.SqlClient.SqlDependency.OnChange> event. For more information about the requirements for creating queries for notifications, see [Working with Query Notifications](/sql/relational-databases/native-client/features/working-with-query-notifications).
|
||
|
|
||
|
> [!NOTE]
|
||
|
> <xref:Microsoft.Data.SqlClient.SqlDependency> was designed to be used in ASP.NET or middle-tier services where there is a relatively small number of servers having dependencies active against the database. It was not designed for use in client applications, where hundreds or thousands of client computers would have <xref:Microsoft.Data.SqlClient.SqlDependency> objects set up for a single database server. If you are developing an application where you need reliable sub-second notifications when data changes, review the sections [Planning an Efficient Query Notifications Strategy](https://docs.microsoft.com/previous-versions/sql/sql-server-2008-r2/ms187528(v=sql.105)#planning-an-efficient-query-notifications-strategy) and [Alternatives to Query Notifications](https://docs.microsoft.com/previous-versions/sql/sql-server-2008-r2/ms187528(v=sql.105)#alternatives-to-query-notifications) in the [Planning for Notifications](https://docs.microsoft.com/previous-versions/sql/sql-server-2008-r2/ms187528(v%3dsql.105)) article.
|
||
|
|
||
|
For more information, see [Query Notifications in SQL Server](/sql/connect/ado-net/sql/query-notifications-sql-server) and [Building Notification Solutions](https://docs.microsoft.com/previous-versions/sql/sql-server-2005/ms171065(v%3dsql.90)).
|
||
|
|
||
|
> [!NOTE]
|
||
|
> The <xref:Microsoft.Data.SqlClient.SqlDependency.OnChange> event may be generated on a different thread from the thread that initiated command execution.
|
||
|
|
||
|
Query notifications are supported only for SELECT statements that meet a list of specific requirements.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDependency.#ctor">
|
||
|
<summary>Creates a new instance of the <see cref="T:Microsoft.Data.SqlClient.SqlDependency" /> class with the default settings.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The constructor initializes the <xref:Microsoft.Data.SqlClient.SqlDependency> object using the default Service Broker service name and time-out. At some point after construction, you must use the <xref:Microsoft.Data.SqlClient.SqlDependency.AddCommandDependency%2A> method to associate one or more commands to this <xref:Microsoft.Data.SqlClient.SqlDependency> object.
|
||
|
|
||
|
Query notifications are supported only for SELECT statements that meet a list of specific requirements. For more information, see [SQL Server Service Broker](/sql/database-engine/configure-windows/sql-server-service-broker) and [Working with Query Notifications](/sql/connect/oledb/features/working-with-query-notifications).
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDependency.#ctor(Microsoft.Data.SqlClient.SqlCommand)">
|
||
|
<param name="command">The <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> object to associate with this <see cref="T:Microsoft.Data.SqlClient.SqlDependency" /> object. The constructor will set up a <see cref="T:Microsoft.Data.Sql.SqlNotificationRequest" /> object and bind it to the command.</param><summary>Creates a new instance of the <see cref="T:Microsoft.Data.SqlClient.SqlDependency" /> class and associates it with the <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> parameter.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Internally, this constructor creates an instance of the <xref:Microsoft.Data.Sql.SqlNotificationRequest> class, and binds it to a <xref:Microsoft.Data.SqlClient.SqlCommand> object.
|
||
|
|
||
|
Query notifications are supported only for SELECT statements that meet a list of specific requirements. For more information, see [SQL Server Service Broker](/sql/database-engine/configure-windows/sql-server-service-broker) and [Working with Query Notifications](/sql/connect/oledb/features/working-with-query-notifications).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">The <paramref name="command" /> parameter is NULL.</exception><exception cref="T:System.InvalidOperationException">The <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> object already has a <see cref="T:Microsoft.Data.Sql.SqlNotificationRequest" /> object assigned to its <see cref="P:Microsoft.Data.SqlClient.SqlCommand.Notification" /> property, and that <see cref="T:Microsoft.Data.Sql.SqlNotificationRequest" /> is not associated with this dependency.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDependency.#ctor(Microsoft.Data.SqlClient.SqlCommand,System.String,System.Int32)">
|
||
|
<param name="command">The <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> object to associate with this <see cref="T:Microsoft.Data.SqlClient.SqlDependency" /> object. The constructor sets up a <see cref="T:Microsoft.Data.Sql.SqlNotificationRequest" /> object and bind it to the command.</param><param name="options">The notification request options to be used by this dependency. <see langword="null" /> to use the default service.</param><param name="timeout">The time-out for this notification in seconds. The default is 0, indicating that the server's time-out should be used.</param><summary>Creates a new instance of the <see cref="T:Microsoft.Data.SqlClient.SqlDependency" /> class, associates it with the <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> parameter, and specifies notification options and a time-out value.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Query notifications are supported only for SELECT statements that meet a list of specific requirements. For more information, see [SQL Server Service Broker](/sql/database-engine/configure-windows/sql-server-service-broker) and [Working with Query Notifications](/sql/connect/oledb/features/working-with-query-notifications).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">The <paramref name="command" /> parameter is NULL.</exception><exception cref="T:System.ArgumentOutOfRangeException">The time-out value is less than zero.</exception><exception cref="T:System.InvalidOperationException">The <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> object already has a <see cref="T:Microsoft.Data.Sql.SqlNotificationRequest" /> object assigned to its <see cref="P:Microsoft.Data.SqlClient.SqlCommand.Notification" /> property and that <see cref="T:Microsoft.Data.Sql.SqlNotificationRequest" /> is not associated with this dependency.
|
||
|
|
||
|
An attempt was made to create a **SqlDependency** instance from within SQLCLR.</exception>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlDependency.HasChanges">
|
||
|
<summary>Gets a value that indicates whether one of the result sets associated with the dependency has changed.</summary><value>A Boolean value indicating whether one of the result sets has changed.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
If you are not using the <xref:Microsoft.Data.SqlClient.SqlDependency.OnChange> event, you can check the <xref:Microsoft.Data.SqlClient.SqlDependency.HasChanges%2A> property to determine if the query results have changed.
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlDependency.HasChanges%2A> property does not necessarily imply a change in the data. Other circumstances, such as time-out expired and failure to set the notification request, also generate a change event.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlDependency.Id">
|
||
|
<summary>Gets a value that uniquely identifies this instance of the <see cref="T:Microsoft.Data.SqlClient.SqlDependency" /> class.</summary><value>A string representation of a GUID that is generated for each instance of the <see cref="T:Microsoft.Data.SqlClient.SqlDependency" /> class.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlDependency.Id%2A> property is used to uniquely identify a given <xref:Microsoft.Data.SqlClient.SqlDependency> instance.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="E:Microsoft.Data.SqlClient.SqlDependency.OnChange">
|
||
|
<summary>Occurs when a notification is received for any of the commands associated with this <see cref="T:Microsoft.Data.SqlClient.SqlDependency" /> object.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
<xref:Microsoft.Data.SqlClient.SqlDependency.OnChange> occurs when the results for the associated command change. If you are not using <xref:Microsoft.Data.SqlClient.SqlDependency.OnChange>, you can check the <xref:Microsoft.Data.SqlClient.SqlDependency.HasChanges%2A> property to determine whether the query results have changed.
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlDependency.OnChange> event does not necessarily imply a change in the data. Other circumstances, such as time-out expired and failure to set the notification request, also generate <xref:Microsoft.Data.SqlClient.SqlDependency.OnChange>.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDependency.AddCommandDependency(Microsoft.Data.SqlClient.SqlCommand)">
|
||
|
<param name="command">A <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> object containing a statement that is valid for notifications.</param><summary>Associates a <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> object with this <see cref="T:Microsoft.Data.SqlClient.SqlDependency" /> instance.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Query notifications are supported only for SELECT statements that meet a list of specific requirements. For more information, see [SQL Server Service Broker](/sql/database-engine/configure-windows/sql-server-service-broker) and [Working with Query Notifications](/sql/connect/oledb/features/working-with-query-notifications).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">The <paramref name="command" /> parameter is null.</exception><exception cref="T:System.InvalidOperationException">The <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> object already has a <see cref="T:Microsoft.Data.Sql.SqlNotificationRequest" /> object assigned to its <see cref="P:Microsoft.Data.SqlClient.SqlCommand.Notification" /> property, and that <see cref="T:Microsoft.Data.Sql.SqlNotificationRequest" /> is not associated with this dependency.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDependency.Start(System.String)">
|
||
|
<param name="connectionString">The connection string for the instance of SQL Server from which to obtain change notifications.</param><summary>Starts the listener for receiving dependency change notifications from the instance of SQL Server specified by the connection string.</summary><returns>
|
||
|
<see langword="true" /> if the listener initialized successfully; <see langword="false" /> if a compatible listener already exists.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This method starts the listener for the <xref:System.AppDomain> for receiving dependency notifications from the instance of SQL Server specified by the `connectionString` parameter. This method may be called more than once with different connection strings for multiple servers.
|
||
|
|
||
|
For additional remarks, see <xref:Microsoft.Data.SqlClient.SqlDependency.Start%2A>.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">The <paramref name="connectionString" /> parameter is NULL.</exception><exception cref="T:System.InvalidOperationException">The <paramref name="connectionString" /> parameter is the same as a previous call to this method, but the parameters are different.
|
||
|
|
||
|
The method was called from within the CLR.</exception><exception cref="T:System.Security.SecurityException">The caller does not have the required <see cref="T:Microsoft.Data.SqlClient.SqlClientPermission" /> code access security (CAS) permission.</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">A subsequent call to the method has been made with an equivalent <paramref name="connectionString" /> parameter with a different user, or a user that does not default to the same schema.
|
||
|
|
||
|
Also, any underlying **SqlClient** exceptions.</exception><altmember cref="P:Microsoft.Data.SqlClient.SqlConnection.ConnectionString" />
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDependency.Start(System.String,System.String)">
|
||
|
<param name="connectionString">The connection string for the instance of SQL Server from which to obtain change notifications.</param><param name="queue">An existing SQL Server Service Broker queue to be used. If <see langword="null" />, the default queue is used.</param><summary>Starts the listener for receiving dependency change notifications from the instance of SQL Server specified by the connection string using the specified SQL Server Service Broker queue.</summary><returns>
|
||
|
<see langword="true" /> if the listener initialized successfully; <see langword="false" /> if a compatible listener already exists.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This method starts the listener for the <xref:System.AppDomain> for receiving dependency notifications from the instance of SQL Server specified by the `connectionString` parameter. This method may be called more than once with different connection strings for multiple servers.
|
||
|
|
||
|
If no queue name is specified, <xref:Microsoft.Data.SqlClient.SqlDependency> creates a temporary queue and service in the server that is used for the entire process, even if the process involves more than one <xref:System.AppDomain>. The queue and service are automatically removed upon application shutdown.
|
||
|
|
||
|
For additional remarks, see <xref:Microsoft.Data.SqlClient.SqlDependency.Start%2A>.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">The <paramref name="connectionString" /> parameter is NULL.</exception><exception cref="T:System.InvalidOperationException">The <paramref name="connectionString" /> parameter is the same as a previous call to this method, but the parameters are different.
|
||
|
|
||
|
The method was called from within the CLR.</exception><exception cref="T:System.Security.SecurityException">The caller does not have the required <see cref="T:Microsoft.Data.SqlClient.SqlClientPermission" /> code access security (CAS) permission.</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">A subsequent call to the method has been made with an equivalent <paramref name="connectionString" /> parameter but a different user, or a user that does not default to the same schema.
|
||
|
|
||
|
Also, any underlying **SqlClient** exceptions.</exception><altmember cref="P:Microsoft.Data.SqlClient.SqlConnection.ConnectionString" />
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDependency.Stop(System.String)">
|
||
|
<param name="connectionString">Connection string for the instance of SQL Server that was used in a previous <see cref="M:Microsoft.Data.SqlClient.SqlDependency.Start(System.String)" /> call.</param><summary>Stops a listener for a connection specified in a previous <see cref="M:Microsoft.Data.SqlClient.SqlDependency.Start(System.String)" /> call.</summary><returns>
|
||
|
<see langword="true" /> if the listener was completely stopped; <see langword="false" /> if the <see cref="T:System.AppDomain" /> was unbound from the listener, but there are is at least one other <see cref="T:System.AppDomain" /> using the same listener.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlDependency.Stop%2A> method must be called for each <xref:Microsoft.Data.SqlClient.SqlDependency.Start%2A> call. A given listener only shuts down fully when it receives the same number of <xref:Microsoft.Data.SqlClient.SqlDependency.Stop%2A> requests as <xref:Microsoft.Data.SqlClient.SqlDependency.Start%2A> requests.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">The <paramref name="connectionString" /> parameter is NULL.</exception><exception cref="T:System.InvalidOperationException">The method was called from within SQLCLR.</exception><exception cref="T:System.Security.SecurityException">The caller does not have the required <see cref="T:Microsoft.Data.SqlClient.SqlClientPermission" /> code access security (CAS) permission.</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">An underlying **SqlClient** exception occurred.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlDependency.Stop(System.String,System.String)">
|
||
|
<param name="connectionString">Connection string for the instance of SQL Server that was used in a previous <see cref="M:Microsoft.Data.SqlClient.SqlDependency.Start(System.String,System.String)" /> call.</param><param name="queue">The SQL Server Service Broker queue that was used in a previous <see cref="M:Microsoft.Data.SqlClient.SqlDependency.Start(System.String,System.String)" /> call.</param><summary>Stops a listener for a connection specified in a previous <see cref="M:Microsoft.Data.SqlClient.SqlDependency.Start(System.String,System.String)" /> call.</summary><returns>
|
||
|
<see langword="true" /> if the listener was completely stopped; <see langword="false" /> if the <see cref="T:System.AppDomain" /> was unbound from the listener, but there is at least one other <see cref="T:System.AppDomain" /> using the same listener.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlDependency.Stop%2A> method must be called for each <xref:Microsoft.Data.SqlClient.SqlDependency.Start%2A> call. A given listener only shuts down fully when it receives the same number of <xref:Microsoft.Data.SqlClient.SqlDependency.Stop%2A> requests as <xref:Microsoft.Data.SqlClient.SqlDependency.Start%2A> requests.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">The <paramref name="connectionString" /> parameter is NULL.</exception><exception cref="T:System.InvalidOperationException">The method was called from within SQLCLR.</exception><exception cref="T:System.Security.SecurityException">The caller does not have the required <see cref="T:Microsoft.Data.SqlClient.SqlClientPermission" /> code access security (CAS) permission.</exception><exception cref="T:Microsoft.Data.SqlClient.SqlException">And underlying **SqlClient** exception occurred.</exception>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlError">
|
||
|
<summary>Collects information relevant to a warning or error returned by SQL Server.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This class is created by the .NET Framework Data Provider for SQL Server when an error occurs. An instance of <xref:Microsoft.Data.SqlClient.SqlError> is created and managed by the <xref:Microsoft.Data.SqlClient.SqlErrorCollection>, which in turn is created by the <xref:Microsoft.Data.SqlClient.SqlException> class.
|
||
|
|
||
|
Messages with a severity level of 10 or less are informational and indicate problems caused by mistakes in information that a user has entered. Severity levels from 11 through 16 are generated by the user, and can be corrected by the user. Severity levels from 17 through 25 indicate software or hardware errors. When a level 17, 18, or 19 error occurs, you can continue working, although you might not be able to execute a particular statement.
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlConnection> remains open when the severity level is 19 or less. When the severity level is 20 or greater, the server usually closes the <xref:Microsoft.Data.SqlClient.SqlConnection>. However, the user can reopen the connection and continue. In both cases, a <xref:Microsoft.Data.SqlClient.SqlException> is generated by the method executing the command.
|
||
|
|
||
|
For more information on errors generated by SQL Server, see [Cause and Resolution of Database Engine Errors](https://msdn.microsoft.com/library/ms365262.aspx). For more information about severity levels, see [Database Engine Error Severities](https://msdn.microsoft.com/library/ms164086.aspx).
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example displays each <xref:Microsoft.Data.SqlClient.SqlError> within the <xref:Microsoft.Data.SqlClient.SqlErrorCollection> collection.
|
||
|
|
||
|
[!code-csharp[SqlError_ToString Example#1](~/../sqlclient/doc/samples/SqlError_ToString.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><altmember cref="T:Microsoft.Data.SqlClient.SqlErrorCollection" /><altmember cref="T:Microsoft.Data.SqlClient.SqlException" />
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlError.Class">
|
||
|
<summary>Gets the severity level of the error returned from SQL Server.</summary><value>A value from 1 to 25 that indicates the severity level of the error. The default is 0.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Messages with a severity level of 10 or less are informational and indicate problems caused by mistakes in information that a user has entered. Severity levels from 11 through 16 are generated by the user, and can be corrected by the user. Severity levels from 17 through 25 indicate software or hardware errors. When a level 17, 18, or 19 error occurs, you can continue working, although you might not be able to execute a particular statement.
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlConnection> remains open when the severity level is 19 or less. When the severity level is 20 or greater, the server usually closes the <xref:Microsoft.Data.SqlClient.SqlConnection>. However, the user can reopen the connection and continue. In both cases, a <xref:Microsoft.Data.SqlClient.SqlException> is generated by the method executing the command.
|
||
|
|
||
|
For more information on errors generated by SQL Server, see [Database Engine Events and Errors](/sql/relational-databases/errors-events/database-engine-events-and-errors).
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example displays each <xref:Microsoft.Data.SqlClient.SqlError> within the <xref:Microsoft.Data.SqlClient.SqlErrorCollection> collection.
|
||
|
|
||
|
[!code-csharp[SqlError_State Example#1](~/../sqlclient/doc/samples/SqlError_State.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlError.LineNumber">
|
||
|
<summary>Gets the line number within the Transact-SQL command batch or stored procedure that contains the error.</summary><value>The line number within the Transact-SQL command batch or stored procedure that contains the error.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Line numbering starts at 1. If the value is 0, the line number is not applicable.
|
||
|
|
||
|
For more information on errors generated by SQL Server, see [Database Engine Events and Errors](/sql/relational-databases/errors-events/database-engine-events-and-errors).
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example displays each <xref:Microsoft.Data.SqlClient.SqlError> within the <xref:Microsoft.Data.SqlClient.SqlErrorCollection> collection.
|
||
|
|
||
|
[!code-csharp[SqlError.State Example#1](~/../sqlclient/doc/samples/SqlError_State.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlError.Message">
|
||
|
<summary>Gets the text describing the error.</summary><value>The text describing the error. For more information on errors generated by SQL Server, see <see href="/sql/relational-databases/errors-events/database-engine-events-and-errors">Database Engine Events and Errors</see>.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Examples
|
||
|
The following example displays each <xref:Microsoft.Data.SqlClient.SqlError> within the <xref:Microsoft.Data.SqlClient.SqlErrorCollection> collection.
|
||
|
|
||
|
[!code-csharp[SqlError.State Example#1](~/../sqlclient/doc/samples/SqlError_State.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlError.Number">
|
||
|
<summary>Gets a number that identifies the type of error.</summary><value>The number that identifies the type of error.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The following table describes the possible values for this property:
|
||
|
|
||
|
|Source of Error|SqlError.Number|SqlError.State|SqlException has inner Win32Exception (beginning with.NET Framework 4.5)|
|
||
|
|---------------------|---------------------|--------------------|--------------------------------------------------------------------------------|
|
||
|
|Error from server|Server error code<br /><br /> This number corresponds to an entry in the `master.dbo.sysmessages` table.|Typically greater than 0|No|
|
||
|
|Connection timeout|-2|0|Yes (Number = 258)|
|
||
|
|Communication error (non-LocalDB)|Win32 error code|0|Yes (Number = Win32 error code)|
|
||
|
|Communication error (LocalDB)|Win32 error code|0|No|
|
||
|
|Encryption capability mismatch|20|0|No|
|
||
|
|Failed to start LocalDB|Win32 error code|0|No|
|
||
|
|Read-only routing failure|0|0|No|
|
||
|
|Server had severe error processing query|0|0|No|
|
||
|
|Processed cancellation while parsing results|0|0|No|
|
||
|
|Failed to create user instance|0|0|No|
|
||
|
|
||
|
For more information on errors generated by SQL Server, see [Database Engine Events and Errors](/sql/relational-databases/errors-events/database-engine-events-and-errors).
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example displays each <xref:Microsoft.Data.SqlClient.SqlError> within the <xref:Microsoft.Data.SqlClient.SqlErrorCollection> collection.
|
||
|
|
||
|
[!code-csharp[SqlError.State Example#1](~/../sqlclient/doc/samples/SqlError_State.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlError.Procedure">
|
||
|
<summary>Gets the name of the stored procedure or remote procedure call (RPC) that generated the error.</summary><value>The name of the stored procedure or RPC. For more information on errors generated by SQL Server, see <see href="/sql/relational-databases/errors-events/database-engine-events-and-errors">Database Engine Events and Errors</see>.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Examples
|
||
|
The following example displays each <xref:Microsoft.Data.SqlClient.SqlError> within the <xref:Microsoft.Data.SqlClient.SqlErrorCollection> collection.
|
||
|
|
||
|
[!code-csharp[SqlError.State Example#1](~/../sqlclient/doc/samples/SqlError_State.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlError.Server">
|
||
|
<summary>Gets the name of the instance of SQL Server that generated the error.</summary><value>The name of the instance of SQL Server.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Examples
|
||
|
The following example displays each <xref:Microsoft.Data.SqlClient.SqlError> within the <xref:Microsoft.Data.SqlClient.SqlErrorCollection> collection.
|
||
|
|
||
|
[!code-csharp[SqlError.State Example#1](~/../sqlclient/doc/samples/SqlError_State.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlError.Source">
|
||
|
<summary>Gets the name of the provider that generated the error.</summary><value>The name of the provider that generated the error.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Examples
|
||
|
The following example displays each <xref:Microsoft.Data.SqlClient.SqlError> within the <xref:Microsoft.Data.SqlClient.SqlErrorCollection> collection.
|
||
|
|
||
|
[!code-csharp[SqlError.State Example#1](~/../sqlclient/doc/samples/SqlError_State.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlError.State">
|
||
|
<summary>Some error messages can be raised at multiple points in the code for the Database Engine. For example, an 1105 error can be raised for several different conditions. Each specific condition that raises an error assigns a unique state code.</summary><value>The state code.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
State is only set for errors that are received from the server.
|
||
|
|
||
|
For more information on errors generated by SQL Server, see [Understanding Database Engine Errors](https://msdn.microsoft.com/library/ms165761.aspx).
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example displays each <xref:Microsoft.Data.SqlClient.SqlError> within the <xref:Microsoft.Data.SqlClient.SqlErrorCollection> collection.
|
||
|
|
||
|
[!code-csharp[SqlError.State Example#1](~/../sqlclient/doc/samples/SqlError_State.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlError.ToString">
|
||
|
<summary>Gets the complete text of the error message.</summary><returns>The complete text of the error.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The string is in the form "SqlError:", followed by the <xref:Microsoft.Data.SqlClient.SqlError.Message%2A>, and the stack trace. For example:
|
||
|
|
||
|
SqlError:UserId or Password not valid. \<stack trace>
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example displays each <xref:Microsoft.Data.SqlClient.SqlError> within the <xref:Microsoft.Data.SqlClient.SqlErrorCollection> collection.
|
||
|
|
||
|
[!code-csharp[SqlError_ToString Example#1](~/../sqlclient/doc/samples/SqlError_ToString.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlErrorCollection">
|
||
|
<summary>Collects all errors generated by the .NET Framework Data Provider for SQL Server. This class cannot be inherited.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This class is created by <xref:Microsoft.Data.SqlClient.SqlException> to collect instances of the <xref:Microsoft.Data.SqlClient.SqlError> class. <xref:Microsoft.Data.SqlClient.SqlErrorCollection> always contains at least one instance of the <xref:Microsoft.Data.SqlClient.SqlError> class.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example displays each <xref:Microsoft.Data.SqlClient.SqlError> within the <xref:Microsoft.Data.SqlClient.SqlErrorCollection> collection.
|
||
|
|
||
|
[!code-csharp[SqlError_ToString Example#1](~/../sqlclient/doc/samples/SqlError_ToString.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><altmember cref="T:Microsoft.Data.SqlClient.SqlError" /><altmember cref="T:Microsoft.Data.SqlClient.SqlException" />
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlErrorCollection.Count">
|
||
|
<summary>Gets the number of errors in the collection.</summary><value>The total number of errors in the collection.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Examples
|
||
|
The following example displays each <xref:Microsoft.Data.SqlClient.SqlError> within the <xref:Microsoft.Data.SqlClient.SqlErrorCollection> collection.
|
||
|
|
||
|
[!code-csharp[SqlError_ToString Example#1](~/../sqlclient/doc/samples/SqlError_ToString.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlErrorCollection.Item(System.Int32)">
|
||
|
<param name="index">The zero-based index of the error to retrieve.</param><summary>Gets the error at the specified index.</summary><value>A <see cref="T:Microsoft.Data.SqlClient.SqlError" /> that contains the error at the specified index.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Examples
|
||
|
The following example displays each <xref:Microsoft.Data.SqlClient.SqlError> within the <xref:Microsoft.Data.SqlClient.SqlErrorCollection> collection.
|
||
|
|
||
|
[!code-csharp[SqlError_ToString Example#1](~/../sqlclient/doc/samples/SqlError_ToString.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.IndexOutOfRangeException">Index parameter is outside array bounds.</exception><altmember cref="P:Microsoft.Data.SqlClient.SqlErrorCollection.Count" />
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlErrorCollection.System#Collections#ICollection#IsSynchronized">
|
||
|
<summary>For a description of this member, see <see cref="P:System.Collections.ICollection.IsSynchronized" />.</summary><value>
|
||
|
<see langword="true" /> if access to the <see cref="T:System.Collections.ICollection" /> is synchronized (thread safe); otherwise, <see langword="false" />.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This member is an explicit interface member implementation. It can be used only when the <xref:Microsoft.Data.SqlClient.SqlErrorCollection> instance is cast to an <xref:System.Collections.ICollection> interface.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlErrorCollection.System#Collections#ICollection#SyncRoot">
|
||
|
<summary>For a description of this member, see <see cref="P:System.Collections.ICollection.SyncRoot" />.</summary><value>An object that can be used to synchronize access to the <see cref="T:System.Collections.ICollection" />.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This member is an explicit interface member implementation. It can be used only when the <xref:Microsoft.Data.SqlClient.SqlErrorCollection> instance is cast to an <xref:System.Collections.ICollection> interface.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlErrorCollection.CopyTo(System.Array,System.Int32)">
|
||
|
<param name="array">The <see cref="T:System.Array" /> to copy elements into.</param><param name="index">The index from which to start copying into the <paramref name="array" /> parameter.</param><summary>Copies the elements of the <see cref="T:Microsoft.Data.SqlClient.SqlErrorCollection" /> collection into an <see cref="T:System.Array" />, starting at the specified index.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">The sum of <paramref name="index" /> and the number of elements in the <see cref="T:Microsoft.Data.SqlClient.SqlErrorCollection" /> collection is greater than the <see cref="P:System.Array.Length" /> of the <see cref="T:System.Array" />.</exception><exception cref="T:System.ArgumentNullException">The <paramref name="array" /> is <see langword="null" />.</exception><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="index" /> is not valid for <paramref name="array" />.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlErrorCollection.CopyTo(Microsoft.Data.SqlClient.SqlError[],System.Int32)">
|
||
|
<param name="array">The <see cref="T:Microsoft.Data.SqlClient.SqlErrorCollection" /> to copy the elements into.</param><param name="index">The index from which to start copying into the <paramref name="array" /> parameter.</param><summary>Copies the elements of the <see cref="T:Microsoft.Data.SqlClient.SqlErrorCollection" /> collection into a <see cref="T:Microsoft.Data.SqlClient.SqlErrorCollection" />, starting at the specified index.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">The sum of <paramref name="index" /> and the number of elements in the <see cref="T:Microsoft.Data.SqlClient.SqlErrorCollection" /> collection is greater than the length of the <see cref="T:Microsoft.Data.SqlClient.SqlErrorCollection" />.</exception><exception cref="T:System.ArgumentNullException">The <paramref name="array" /> is <see langword="null" />.</exception><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="index" /> is not valid for <paramref name="array" />.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlErrorCollection.GetEnumerator">
|
||
|
<summary>Returns an enumerator that iterates through the <see cref="T:Microsoft.Data.SqlClient.SqlErrorCollection" />.</summary><returns>An <see cref="T:System.Collections.IEnumerator" /> for the <see cref="T:Microsoft.Data.SqlClient.SqlErrorCollection" />.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Enumerators can be used to read the data in a collection, but they cannot be used to modify the underlying collection.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlException">
|
||
|
<summary>The exception that is thrown when SQL Server returns a warning or error. This class cannot be inherited.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This class is created whenever the .NET Framework Data Provider for SQL Server encounters an error generated from the server. (Client side errors are thrown as standard common language runtime exceptions.) <xref:Microsoft.Data.SqlClient.SqlException> always contains at least one instance of <xref:Microsoft.Data.SqlClient.SqlError>.
|
||
|
|
||
|
Messages that have a severity level of 10 or less are informational and indicate problems caused by mistakes in information that a user has entered. Severity levels from 11 through 16 are generated by the user, and can be corrected by the user. Severity levels from 17 through 25 indicate software or hardware errors. When a level 17, 18, or 19 error occurs, you can continue working, although you might not be able to execute a particular statement.
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlConnection> remains open when the severity level is 19 or less. When the severity level is 20 or greater, the server ordinarily closes the <xref:Microsoft.Data.SqlClient.SqlConnection>. However, the user can reopen the connection and continue. In both cases, a <xref:Microsoft.Data.SqlClient.SqlException> is generated by the method executing the command.
|
||
|
|
||
|
For information about the warning and informational messages sent by SQL Server, see [Database Engine Events and Errors](/sql/relational-databases/errors-events/database-engine-events-and-errors). The <xref:Microsoft.Data.SqlClient.SqlException> class maps to SQL Server severity.
|
||
|
|
||
|
The following is general information on handling exceptions. Your code should catch exceptions to prevent the application from crashing and to allow displaying a relevant error message to the user. You can use database transactions to ensure that the data is consistent regardless of what happens in the client application (including a crash). Features like System.Transaction.TransactionScope or the BeginTransaction method (in System.Data.OleDb.OleDbConnection, System.Data.ODBC.ODBCConnection, and Microsoft.Data.SqlClient.SqlConnection) ensure consistent data regardless of exceptions raised by a provider. Transactions can fail, so catch failures and retry the transaction.
|
||
|
|
||
|
Note that beginning with .NET Framework 4.5, <xref:Microsoft.Data.SqlClient.SqlException> can return an inner <xref:System.ComponentModel.Win32Exception>.
|
||
|
|
||
|
The exception class of a .NET Framework data provider reports provider-specific errors. For example System.Data.Odbc has OdbcException, System.Data.OleDb has OleDbException, and Microsoft.Data.SqlClient has SqlException. For the best level of error detail, catch these exceptions and use the members of these exception classes to get details of the error.
|
||
|
|
||
|
In addition to the provider-specific errors, .NET Framework data provider types can raise .NET Framework exceptions such as System.OutOfMemoryException and System.Threading.ThreadAbortException. Recovery from these exceptions may not be possible.
|
||
|
|
||
|
Bad input can cause a .NET Framework data provider type to raise an exception such as System.ArgumentException or System.IndexOutOfRangeException. Calling a method at the wrong time can raise System.InvalidOperationException.
|
||
|
|
||
|
So, in general, write an exception handler that catches any provider specific exceptions as well as exceptions from the common language runtime. These can be layered as follows:
|
||
|
|
||
|
```csharp
|
||
|
try {
|
||
|
// code here
|
||
|
}
|
||
|
catch (SqlException odbcEx) {
|
||
|
// Handle more specific SqlException exception here.
|
||
|
}
|
||
|
catch (Exception ex) {
|
||
|
// Handle generic ones here.
|
||
|
}
|
||
|
|
||
|
```
|
||
|
|
||
|
Or:
|
||
|
|
||
|
```csharp
|
||
|
try {
|
||
|
// code here
|
||
|
}
|
||
|
catch (Exception ex) {
|
||
|
if (ex is SqlException) {
|
||
|
// Handle more specific SqlException exception here.
|
||
|
}
|
||
|
else {
|
||
|
// Handle generic ones here.
|
||
|
}
|
||
|
}
|
||
|
|
||
|
```
|
||
|
|
||
|
It is also possible for a .NET Framework data provider method call to fail on a thread pool thread with no user code on the stack. In this case, and when using asynchronous method calls, you must register the <xref:System.AppDomain.UnhandledException> event to handle those exceptions and avoid application crash.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example generates a <xref:Microsoft.Data.SqlClient.SqlException> and then displays the exception.
|
||
|
|
||
|
[!code-csharp[SqlException_Errors1 Example#1](~/../sqlclient/doc/samples/SqlException_Errors1.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><altmember cref="T:Microsoft.Data.SqlClient.SqlError" /><altmember cref="T:Microsoft.Data.SqlClient.SqlErrorCollection" />
|
||
|
<summary>The exception that is thrown when SQL Server returns a warning or error. This class cannot be inherited.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This class is created whenever the .NET Framework Data Provider for SQL Server encounters an error generated from the server. (Client side errors are thrown as standard common language runtime exceptions.) <xref:Microsoft.Data.SqlClient.SqlException> always contains at least one instance of <xref:Microsoft.Data.SqlClient.SqlError>.
|
||
|
|
||
|
Messages that have a severity level of 10 or less are informational and indicate problems caused by mistakes in information that a user has entered. Severity levels from 11 through 16 are generated by the user, and can be corrected by the user. Severity levels from 17 through 25 indicate software or hardware errors. When a level 17, 18, or 19 error occurs, you can continue working, although you might not be able to execute a particular statement.
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlConnection> remains open when the severity level is 19 or less. When the severity level is 20 or greater, the server ordinarily closes the <xref:Microsoft.Data.SqlClient.SqlConnection>. However, the user can reopen the connection and continue. In both cases, a <xref:Microsoft.Data.SqlClient.SqlException> is generated by the method executing the command.
|
||
|
|
||
|
For information about the warning and informational messages sent by SQL Server, see [Database Engine Events and Errors](/sql/relational-databases/errors-events/database-engine-events-and-errors). The <xref:Microsoft.Data.SqlClient.SqlException> class maps to SQL Server severity.
|
||
|
|
||
|
The following is general information on handling exceptions. Your code should catch exceptions to prevent the application from crashing and to allow displaying a relevant error message to the user. You can use database transactions to ensure that the data is consistent regardless of what happens in the client application (including a crash). Features like System.Transaction.TransactionScope or the BeginTransaction method (in System.Data.OleDb.OleDbConnection, System.Data.ODBC.ODBCConnection, and Microsoft.Data.SqlClient.SqlConnection) ensure consistent data regardless of exceptions raised by a provider. Transactions can fail, so catch failures and retry the transaction.
|
||
|
|
||
|
Note that beginning with .NET Framework 4.5, <xref:Microsoft.Data.SqlClient.SqlException> can return an inner <xref:System.ComponentModel.Win32Exception>.
|
||
|
|
||
|
The exception class of a .NET Framework data provider reports provider-specific errors. For example System.Data.Odbc has OdbcException, System.Data.OleDb has OleDbException, and Microsoft.Data.SqlClient has SqlException. For the best level of error detail, catch these exceptions and use the members of these exception classes to get details of the error.
|
||
|
|
||
|
In addition to the provider-specific errors, .NET Framework data provider types can raise .NET Framework exceptions such as System.OutOfMemoryException and System.Threading.ThreadAbortException. Recovery from these exceptions may not be possible.
|
||
|
|
||
|
Bad input can cause a .NET Framework data provider type to raise an exception such as System.ArgumentException or System.IndexOutOfRangeException. Calling a method at the wrong time can raise System.InvalidOperationException.
|
||
|
|
||
|
So, in general, write an exception handler that catches any provider specific exceptions as well as exceptions from the common language runtime. These can be layered as follows:
|
||
|
|
||
|
```csharp
|
||
|
try {
|
||
|
// code here
|
||
|
}
|
||
|
catch (SqlException odbcEx) {
|
||
|
// Handle more specific SqlException exception here.
|
||
|
}
|
||
|
catch (Exception ex) {
|
||
|
// Handle generic ones here.
|
||
|
}
|
||
|
|
||
|
```
|
||
|
|
||
|
Or:
|
||
|
|
||
|
```csharp
|
||
|
try {
|
||
|
// code here
|
||
|
}
|
||
|
catch (Exception ex) {
|
||
|
if (ex is SqlException) {
|
||
|
// Handle more specific SqlException exception here.
|
||
|
}
|
||
|
else {
|
||
|
// Handle generic ones here.
|
||
|
}
|
||
|
}
|
||
|
|
||
|
```
|
||
|
|
||
|
It is also possible for a .NET Framework data provider method call to fail on a thread pool thread with no user code on the stack. In this case, and when using asynchronous method calls, you must register the <xref:System.AppDomain.UnhandledException> event to handle those exceptions and avoid application crash.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example generates a <xref:Microsoft.Data.SqlClient.SqlException> and then displays the exception.
|
||
|
|
||
|
[!code-csharp[SqlException_Errors1 Example#1](~/../sqlclient/doc/samples/SqlException_Errors1.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><altmember cref="T:Microsoft.Data.SqlClient.SqlError" /><altmember cref="T:Microsoft.Data.SqlClient.SqlErrorCollection" />
|
||
|
<summary>The exception that is thrown when SQL Server returns a warning or error. This class cannot be inherited.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This class is created whenever the .NET Framework Data Provider for SQL Server encounters an error generated from the server. (Client side errors are thrown as standard common language runtime exceptions.) <xref:Microsoft.Data.SqlClient.SqlException> always contains at least one instance of <xref:Microsoft.Data.SqlClient.SqlError>.
|
||
|
|
||
|
Messages that have a severity level of 10 or less are informational and indicate problems caused by mistakes in information that a user has entered. Severity levels from 11 through 16 are generated by the user, and can be corrected by the user. Severity levels from 17 through 25 indicate software or hardware errors. When a level 17, 18, or 19 error occurs, you can continue working, although you might not be able to execute a particular statement.
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlConnection> remains open when the severity level is 19 or less. When the severity level is 20 or greater, the server ordinarily closes the <xref:Microsoft.Data.SqlClient.SqlConnection>. However, the user can reopen the connection and continue. In both cases, a <xref:Microsoft.Data.SqlClient.SqlException> is generated by the method executing the command.
|
||
|
|
||
|
For information about the warning and informational messages sent by SQL Server, see [Database Engine Events and Errors](/sql/relational-databases/errors-events/database-engine-events-and-errors). The <xref:Microsoft.Data.SqlClient.SqlException> class maps to SQL Server severity.
|
||
|
|
||
|
The following is general information on handling exceptions. Your code should catch exceptions to prevent the application from crashing and to allow displaying a relevant error message to the user. You can use database transactions to ensure that the data is consistent regardless of what happens in the client application (including a crash). Features like System.Transaction.TransactionScope or the BeginTransaction method (in System.Data.OleDb.OleDbConnection, System.Data.ODBC.ODBCConnection, and Microsoft.Data.SqlClient.SqlConnection) ensure consistent data regardless of exceptions raised by a provider. Transactions can fail, so catch failures and retry the transaction.
|
||
|
|
||
|
Note that beginning with .NET Framework 4.5, <xref:Microsoft.Data.SqlClient.SqlException> can return an inner <xref:System.ComponentModel.Win32Exception>.
|
||
|
|
||
|
The exception class of a .NET Framework data provider reports provider-specific errors. For example System.Data.Odbc has OdbcException, System.Data.OleDb has OleDbException, and Microsoft.Data.SqlClient has SqlException. For the best level of error detail, catch these exceptions and use the members of these exception classes to get details of the error.
|
||
|
|
||
|
In addition to the provider-specific errors, .NET Framework data provider types can raise .NET Framework exceptions such as System.OutOfMemoryException and System.Threading.ThreadAbortException. Recovery from these exceptions may not be possible.
|
||
|
|
||
|
Bad input can cause a .NET Framework data provider type to raise an exception such as System.ArgumentException or System.IndexOutOfRangeException. Calling a method at the wrong time can raise System.InvalidOperationException.
|
||
|
|
||
|
So, in general, write an exception handler that catches any provider specific exceptions as well as exceptions from the common language runtime. These can be layered as follows:
|
||
|
|
||
|
```csharp
|
||
|
try {
|
||
|
// code here
|
||
|
}
|
||
|
catch (SqlException odbcEx) {
|
||
|
// Handle more specific SqlException exception here.
|
||
|
}
|
||
|
catch (Exception ex) {
|
||
|
// Handle generic ones here.
|
||
|
}
|
||
|
|
||
|
```
|
||
|
|
||
|
Or:
|
||
|
|
||
|
```csharp
|
||
|
try {
|
||
|
// code here
|
||
|
}
|
||
|
catch (Exception ex) {
|
||
|
if (ex is SqlException) {
|
||
|
// Handle more specific SqlException exception here.
|
||
|
}
|
||
|
else {
|
||
|
// Handle generic ones here.
|
||
|
}
|
||
|
}
|
||
|
|
||
|
```
|
||
|
|
||
|
It is also possible for a .NET Framework data provider method call to fail on a thread pool thread with no user code on the stack. In this case, and when using asynchronous method calls, you must register the <xref:System.AppDomain.UnhandledException> event to handle those exceptions and avoid application crash.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example generates a <xref:Microsoft.Data.SqlClient.SqlException> and then displays the exception.
|
||
|
|
||
|
[!code-csharp[SqlException_Errors1 Example#1](~/../sqlclient/doc/samples/SqlException_Errors1.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><altmember cref="T:Microsoft.Data.SqlClient.SqlError" /><altmember cref="T:Microsoft.Data.SqlClient.SqlErrorCollection" />
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlException.Class">
|
||
|
<summary>Gets the severity level of the error returned from the .NET Framework Data Provider for SQL Server.</summary><value>A value from 1 to 25 that indicates the severity level of the error.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Messages that have a severity level of 10 or less are informational and indicate problems caused by mistakes in information that a user has entered. Severity levels from 11 through 16 are generated by the user, and can be corrected by the user. Severity levels from 17 through 25 indicate software or hardware errors. When a level 17, 18, or 19 error occurs, you can continue working, although you might not be able to execute a particular statement.
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlConnection> remains open when the severity level is 19 or less. When the severity level is 20 or greater, the server ordinarily closes the <xref:Microsoft.Data.SqlClient.SqlConnection>. However, the user can reopen the connection and continue. In both cases, a <xref:Microsoft.Data.SqlClient.SqlException> is generated by the method executing the command.
|
||
|
|
||
|
For information about the warning and informational messages sent by SQL Server, see the Troubleshooting section of the SQL Server documentation.
|
||
|
|
||
|
This is a wrapper for the <xref:Microsoft.Data.SqlClient.SqlError.Class%2A> property of the first <xref:Microsoft.Data.SqlClient.SqlError> in the <xref:Microsoft.Data.SqlClient.SqlException.Errors%2A> property.
|
||
|
|
||
|
If <xref:Microsoft.Data.SqlClient.SqlException.Errors%2A> is `null`, the [`default`](https://docs.microsoft.com/dotnet/csharp/language-reference/builtin-types/default-values) value for `byte` is returned.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example displays each <xref:Microsoft.Data.SqlClient.SqlError> within the <xref:Microsoft.Data.SqlClient.SqlErrorCollection> collection.
|
||
|
|
||
|
[!code-csharp[SqlException_Errors2 Example#1](~/../sqlclient/doc/samples/SqlException_Errors2.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><altmember cref="P:Microsoft.Data.SqlClient.SqlException.Number" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.Source" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.State" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.Server" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.Procedure" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.LineNumber" />
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlException.ClientConnectionId">
|
||
|
<summary>Represents the client connection ID. For more information, see <see href="https://docs.microsoft.com/sql/connect/ado-net/data-tracing">Data Tracing in ADO.NET</see>.</summary><value>The client connection ID.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
For a code sample, see <xref:Microsoft.Data.SqlClient.SqlException.ToString%2A>.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlException.Errors">
|
||
|
<summary>Gets a collection of one or more <see cref="T:Microsoft.Data.SqlClient.SqlError" /> objects that give detailed information about exceptions generated by the .NET Framework Data Provider for SQL Server.</summary><value>The collected instances of the <see cref="T:Microsoft.Data.SqlClient.SqlError" /> class.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlErrorCollection> class always contains at least one instance of the <xref:Microsoft.Data.SqlClient.SqlError> class.
|
||
|
|
||
|
This is a wrapper for <xref:Microsoft.Data.SqlClient.SqlErrorCollection>. For more information on SQL Server engine errors, see [Database Engine Events and Errors](/sql/relational-databases/errors-events/database-engine-events-and-errors).
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example displays each <xref:Microsoft.Data.SqlClient.SqlError> within the <xref:Microsoft.Data.SqlClient.SqlErrorCollection> collection.
|
||
|
|
||
|
[!code-csharp[SqlError_ToString Example#1](~/../sqlclient/doc/samples/SqlError_ToString.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><altmember cref="T:Microsoft.Data.SqlClient.SqlErrorCollection" /><altmember cref="T:Microsoft.Data.SqlClient.SqlError" />
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlException.LineNumber">
|
||
|
<summary>Gets the line number within the Transact-SQL command batch or stored procedure that generated the error.</summary><value>The line number within the Transact-SQL command batch or stored procedure that generated the error.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The line numbering starts at 1; if 0 is returned, the line number is not applicable.
|
||
|
|
||
|
This is a wrapper for the <xref:Microsoft.Data.SqlClient.SqlError.LineNumber%2A> property of the first <xref:Microsoft.Data.SqlClient.SqlError> in the <xref:Microsoft.Data.SqlClient.SqlException.Errors%2A> property.
|
||
|
|
||
|
If <xref:Microsoft.Data.SqlClient.SqlException.Errors%2A> is `null`, the [`default`](https://docs.microsoft.com/dotnet/csharp/language-reference/builtin-types/default-values) value for `int` is returned.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example displays each <xref:Microsoft.Data.SqlClient.SqlError> within the <xref:Microsoft.Data.SqlClient.SqlErrorCollection> collection.
|
||
|
|
||
|
[!code-csharp[SqlException_Errors2 Example#1](~/../sqlclient/doc/samples/SqlException_Errors2.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><altmember cref="P:Microsoft.Data.SqlClient.SqlException.Number" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.Source" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.State" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.Class" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.Server" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.Procedure" />
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlException.Number">
|
||
|
<summary>Gets a number that identifies the type of error.</summary><value>The number that identifies the type of error.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This is a wrapper for the <xref:Microsoft.Data.SqlClient.SqlError.Number%2A> property of the first <xref:Microsoft.Data.SqlClient.SqlError> in the <xref:Microsoft.Data.SqlClient.SqlException.Errors%2A> property.
|
||
|
|
||
|
If <xref:Microsoft.Data.SqlClient.SqlException.Errors%2A> is `null`, the [`default`](https://docs.microsoft.com/dotnet/csharp/language-reference/builtin-types/default-values) value for `int` is returned.
|
||
|
|
||
|
For more information on SQL Server engine errors, see [Database Engine Events and Errors](/sql/relational-databases/errors-events/database-engine-events-and-errors).
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example displays each <xref:Microsoft.Data.SqlClient.SqlError> within the <xref:Microsoft.Data.SqlClient.SqlErrorCollection> collection.
|
||
|
|
||
|
[!code-csharp[SqlException_Errors2 Example#1](~/../sqlclient/doc/samples/SqlException_Errors2.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><altmember cref="P:Microsoft.Data.SqlClient.SqlException.State" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.Class" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.Source" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.Server" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.Procedure" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.LineNumber" />
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlException.Procedure">
|
||
|
<summary>Gets the name of the stored procedure or remote procedure call (RPC) that generated the error.</summary><value>The name of the stored procedure or RPC.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This is a wrapper for the <xref:Microsoft.Data.SqlClient.SqlError.Procedure%2A> property of the first <xref:Microsoft.Data.SqlClient.SqlError> in the <xref:Microsoft.Data.SqlClient.SqlException.Errors%2A> property.
|
||
|
|
||
|
If <xref:Microsoft.Data.SqlClient.SqlException.Errors%2A> is `null`, the [`default`](https://docs.microsoft.com/dotnet/csharp/language-reference/builtin-types/default-values) value for `string` is returned.
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example displays each <xref:Microsoft.Data.SqlClient.SqlError> within the <xref:Microsoft.Data.SqlClient.SqlErrorCollection> collection.
|
||
|
|
||
|
[!code-csharp[SqlException_Errors2 Example#1](~/../sqlclient/doc/samples/SqlException_Errors2.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><altmember cref="P:Microsoft.Data.SqlClient.SqlException.Number" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.State" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.Class" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.Server" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.Source" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.LineNumber" />
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlException.Server">
|
||
|
<summary>Gets the name of the computer that is running an instance of SQL Server that generated the error.</summary><value>The name of the computer running an instance of SQL Server.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This is a wrapper for the <xref:Microsoft.Data.SqlClient.SqlError.Server%2A> property of the first <xref:Microsoft.Data.SqlClient.SqlError> in the <xref:Microsoft.Data.SqlClient.SqlException.Errors%2A> property.
|
||
|
|
||
|
If <xref:Microsoft.Data.SqlClient.SqlException.Errors%2A> is `null`, the [`default`](https://docs.microsoft.com/dotnet/csharp/language-reference/builtin-types/default-values) value for `string` is returned.
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example displays each <xref:Microsoft.Data.SqlClient.SqlError> within the <xref:Microsoft.Data.SqlClient.SqlErrorCollection> collection.
|
||
|
|
||
|
[!code-csharp[SqlException_Errors2 Example#1](~/../sqlclient/doc/samples/SqlException_Errors2.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><altmember cref="P:Microsoft.Data.SqlClient.SqlException.Number" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.State" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.Source" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.Class" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.Procedure" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.LineNumber" />
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlException.Source">
|
||
|
<summary>Gets the name of the provider that generated the error.</summary><value>The name of the provider that generated the error.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This is a wrapper for the <xref:Microsoft.Data.SqlClient.SqlError.Source%2A> property of the first <xref:Microsoft.Data.SqlClient.SqlError> in the <xref:Microsoft.Data.SqlClient.SqlException.Errors%2A> property.
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example displays each <xref:Microsoft.Data.SqlClient.SqlError> within the <xref:Microsoft.Data.SqlClient.SqlErrorCollection> collection.
|
||
|
|
||
|
[!code-csharp[SqlException_Errors2 Example#1](~/../sqlclient/doc/samples/SqlException_Errors2.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><altmember cref="P:Microsoft.Data.SqlClient.SqlException.Number" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.State" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.Class" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.Server" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.Procedure" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.LineNumber" />
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlException.State">
|
||
|
<summary>Gets a numeric error code from SQL Server that represents an error, warning or "no data found" message. For more information about how to decode these values, see <see href="/sql/relational-databases/errors-events/database-engine-events-and-errors">Database Engine Events and Errors</see>.</summary><value>The number representing the error code.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This is a wrapper for the <xref:Microsoft.Data.SqlClient.SqlError.State%2A> property of the first <xref:Microsoft.Data.SqlClient.SqlError> in the <xref:Microsoft.Data.SqlClient.SqlException.Errors%2A> property.
|
||
|
|
||
|
If <xref:Microsoft.Data.SqlClient.SqlException.Errors%2A> is `null`, the [`default`](https://docs.microsoft.com/dotnet/csharp/language-reference/builtin-types/default-values) value for `byte` is returned.
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example displays each <xref:Microsoft.Data.SqlClient.SqlError> within the <xref:Microsoft.Data.SqlClient.SqlErrorCollection> collection.
|
||
|
|
||
|
[!code-csharp[SqlException_Errors2 Example#1](~/../sqlclient/doc/samples/SqlException_Errors2.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><altmember cref="P:Microsoft.Data.SqlClient.SqlException.Number" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.Class" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.Source" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.Server" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.Procedure" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.LineNumber" />
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlException.GetObjectData(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)">
|
||
|
<inheritdoc cref="M:System.Exception.GetObjectData(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)" />
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlException.ToString">
|
||
|
<summary>Returns a string that represents the current <see cref="T:Microsoft.Data.SqlClient.SqlException" /> object, and includes the client connection ID (for more information, see <see cref="P:Microsoft.Data.SqlClient.SqlException.ClientConnectionId" />).</summary><returns>A string that represents the current <see cref="T:Microsoft.Data.SqlClient.SqlException" /> object.<see cref="T:System.String" />.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Examples
|
||
|
The following C# example shows how a connection attempt to a valid server but non-existent database causes a <xref:Microsoft.Data.SqlClient.SqlException>, which includes the client connection ID:
|
||
|
|
||
|
```csharp
|
||
|
using Microsoft.Data.SqlClient;
|
||
|
using System;
|
||
|
|
||
|
public class A {
|
||
|
public static void Main() {
|
||
|
SqlConnection connection = new SqlConnection();
|
||
|
connection.ConnectionString = "Data Source=a_valid_server;Initial Catalog=Northwinda;Integrated Security=true";
|
||
|
try {
|
||
|
connection.Open();
|
||
|
}
|
||
|
catch (SqlException p) {
|
||
|
Console.WriteLine("{0}", p.ClientConnectionId);
|
||
|
Console.WriteLine("{0}", p.ToString());
|
||
|
}
|
||
|
connection.Close();
|
||
|
}
|
||
|
}
|
||
|
```
|
||
|
|
||
|
The following Visual Basic sample is functionally equivalent to the previous (C#) sample:
|
||
|
|
||
|
```vb
|
||
|
Imports Microsoft.Data.SqlClient
|
||
|
Imports System
|
||
|
|
||
|
Module Module1
|
||
|
|
||
|
Sub Main()
|
||
|
Dim connection As New SqlConnection()
|
||
|
connection.ConnectionString = "Data Source=a_valid_server;Initial Catalog=Northwinda;Integrated Security=true"
|
||
|
Try
|
||
|
connection.Open()
|
||
|
Catch p As SqlException
|
||
|
Console.WriteLine("{0}", p.ClientConnectionId)
|
||
|
Console.WriteLine("{0}", p.ToString())
|
||
|
End Try
|
||
|
connection.Close()
|
||
|
End Sub
|
||
|
|
||
|
End Module
|
||
|
```
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlException.BatchCommand">
|
||
|
<summary>Gets the BatchCommand instance that generated the error or null if the exception was not raised from a batch.</summary><value>A BatchCommand object or null</value><remarks /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.Number" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.State" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.Class" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.Server" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.Procedure" /><altmember cref="P:Microsoft.Data.SqlClient.SqlException.LineNumber" />
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlException.DbBatchCommand">
|
||
|
<summary>If this <see cref="T:Microsoft.Data.SqlClient.SqlException" /> was thrown when executing a <see cref="T:Microsoft.Data.SqlClient.SqlBatch" />, references the specific <see cref="T:Microsoft.Data.SqlClient.SqlBatchCommand" /> which triggered the exception.</summary><value>The specific <see cref="T:Microsoft.Data.SqlClient.SqlBatchCommand" /> which triggered the exception.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
|
||
|
If this <xref:Microsoft.Data.SqlClient.SqlException> wasn't thrown when executing a <xref:Microsoft.Data.SqlClient.SqlBatch>, the value is `null`.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlInfoMessageEventArgs">
|
||
|
<summary>Provides data for the <see cref="E:Microsoft.Data.SqlClient.SqlConnection.InfoMessage" /> event.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlConnection.InfoMessage> event contains a <xref:Microsoft.Data.SqlClient.SqlErrorCollection> collection which contains the warnings sent from the server.
|
||
|
|
||
|
An <xref:Microsoft.Data.SqlClient.SqlConnection.InfoMessage> event is generated when a SQL Server message with a severity level of 10 or less occurs.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlInfoMessageEventArgs.Errors">
|
||
|
<summary>Gets the collection of warnings sent from the server.</summary><value>The collection of warnings sent from the server.</value><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlInfoMessageEventArgs.Message">
|
||
|
<summary>Gets the full text of the error sent from the database.</summary><value>The full text of the error.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This is a wrapper for the <xref:Microsoft.Data.SqlClient.SqlError.Message%2A> property of the first <xref:Microsoft.Data.SqlClient.SqlError> in the <xref:Microsoft.Data.SqlClient.SqlInfoMessageEventArgs.Errors%2A> collection.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlInfoMessageEventArgs.Source">
|
||
|
<summary>Gets the name of the object that generated the error.</summary><value>The name of the object that generated the error.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This is a wrapper for the <xref:Microsoft.Data.SqlClient.SqlError.Source%2A> property of the first <xref:Microsoft.Data.SqlClient.SqlError> in the <xref:Microsoft.Data.SqlClient.SqlInfoMessageEventArgs.Errors%2A> collection.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlInfoMessageEventArgs.ToString">
|
||
|
<summary>Retrieves a string representation of the <see cref="E:Microsoft.Data.SqlClient.SqlConnection.InfoMessage" /> event.</summary><returns>A string representing the <see cref="E:Microsoft.Data.SqlClient.SqlConnection.InfoMessage" /> event.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlInfoMessageEventHandler">
|
||
|
<param name="sender">The source of the event.</param><param name="e">A <see cref="T:Microsoft.Data.SqlClient.SqlInfoMessageEventArgs" /> object that contains the event data.</param><summary>Represents the method that will handle the <see cref="E:Microsoft.Data.SqlClient.SqlConnection.InfoMessage" /> event of a <see cref="T:Microsoft.Data.SqlClient.SqlConnection" />.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
When you create a <xref:Microsoft.Data.SqlClient.SqlInfoMessageEventArgs> delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](/dotnet/standard/events/).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlNotificationEventArgs">
|
||
|
<summary>Represents the set of arguments passed to the notification event handler.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlNotificationEventArgs.#ctor(Microsoft.Data.SqlClient.SqlNotificationType,Microsoft.Data.SqlClient.SqlNotificationInfo,Microsoft.Data.SqlClient.SqlNotificationSource)">
|
||
|
<param name="type">
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlNotificationType" /> value that indicates whether this notification is generated because of an actual change, or by the subscription.</param><param name="info">
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlNotificationInfo" /> value that indicates the reason for the notification event. This may occur because the data in the store actually changed, or the notification became invalid (for example, it timed out).</param><param name="source">
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlNotificationSource" /> value that indicates the source that generated the notification.</param><summary>Creates a new instance of the <see cref="T:Microsoft.Data.SqlClient.SqlNotificationEventArgs" /> object.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlNotificationEventArgs.Info">
|
||
|
<summary>Gets a value that indicates the reason for the notification event, such as a row in the database being modified or a table being truncated.</summary><value>The notification event reason.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This event may occur because the data in the store actually changed, or the notification is no longer valid (for example, it timed out).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlNotificationEventArgs.Source">
|
||
|
<summary>Gets a value that indicates the source that generated the notification, such as a change to the query data or the database's state.</summary><value>The source of the notification.</value><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlNotificationEventArgs.Type">
|
||
|
<summary>Gets a value that indicates whether this notification is generated because of an actual change, or by the subscription.</summary><value>A value indicating whether the notification was generated by a change or a subscription.</value><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlNotificationInfo">
|
||
|
<summary>This enumeration provides additional information about the different notifications that can be received by the dependency event handler.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlNotificationInfo> enumeration is referenced by an instance of the <xref:Microsoft.Data.SqlClient.SqlNotificationEventArgs> class.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlNotificationInfo.AlreadyChanged">
|
||
|
<summary>The <see langword="SqlDependency" /> object already fired, and new commands cannot be added to it.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlNotificationInfo.Alter">
|
||
|
<summary>An underlying server object related to the query was modified.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlNotificationInfo.Delete">
|
||
|
<summary>Data was changed by a DELETE statement.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlNotificationInfo.Drop">
|
||
|
<summary>An underlying object related to the query was dropped.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlNotificationInfo.Error">
|
||
|
<summary>An internal server error occurred.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlNotificationInfo.Expired">
|
||
|
<summary>The <see langword="SqlDependency" /> object has expired.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlNotificationInfo.Insert">
|
||
|
<summary>Data was changed by an INSERT statement.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlNotificationInfo.Invalid">
|
||
|
<summary>A statement was provided that cannot be notified (for example, an UPDATE statement).</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlNotificationInfo.Isolation">
|
||
|
<summary>The statement was executed under an isolation mode that was not valid (for example, Snapshot).</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlNotificationInfo.Merge">
|
||
|
<summary>Used to distinguish the server-side cause for a query notification firing.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlNotificationInfo.Options">
|
||
|
<summary>The SET options were not set appropriately at subscription time.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlNotificationInfo.PreviousFire">
|
||
|
<summary>A previous statement has caused query notifications to fire under the current transaction.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlNotificationInfo.Query">
|
||
|
<summary>A SELECT statement that cannot be notified or was provided.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlNotificationInfo.Resource">
|
||
|
<summary>Fires as a result of server resource pressure.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlNotificationInfo.Restart">
|
||
|
<summary>The server was restarted (notifications are sent during restart.).</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlNotificationInfo.TemplateLimit">
|
||
|
<summary>The subscribing query causes the number of templates on one of the target tables to exceed the maximum allowable limit.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlNotificationInfo.Truncate">
|
||
|
<summary>One or more tables were truncated.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlNotificationInfo.Unknown">
|
||
|
<summary>Used when the info option sent by the server was not recognized by the client.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlNotificationInfo.Update">
|
||
|
<summary>Data was changed by an UPDATE statement.</summary>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlNotificationSource">
|
||
|
<summary>Indicates the source of the notification received by the dependency event handler.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The `SqlNotificationSource` enumeration is referenced by an instance of the <xref:Microsoft.Data.SqlClient.SqlNotificationEventArgs> class.
|
||
|
|
||
|
Query notifications are supported only for SELECT statements that meet a list of specific requirements. For more information, see [SQL Server Service Broker](/sql/database-engine/configure-windows/sql-server-service-broker) and [Working with Query Notifications](/sql/connect/oledb/features/working-with-query-notifications).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlNotificationSource.Client">
|
||
|
<summary>A client-initiated notification occurred, such as a client-side time-out or as a result of attempting to add a command to a dependency that has already fired.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlNotificationSource.Data">
|
||
|
<summary>Data has changed; for example, an insert, update, delete, or truncate operation occurred.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlNotificationSource.Database">
|
||
|
<summary>The database state changed; for example, the database related to the query was dropped or detached.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlNotificationSource.Environment">
|
||
|
<summary>The run-time environment was not compatible with notifications; for example, the isolation level was set to snapshot, or one or more SET options are not compatible.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlNotificationSource.Execution">
|
||
|
<summary>A run-time error occurred during execution.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlNotificationSource.Object">
|
||
|
<summary>A database object changed; for example, an underlying object related to the query was dropped or modified.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlNotificationSource.Owner">
|
||
|
<summary>Internal only; not intended to be used in your code.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlNotificationSource.Statement">
|
||
|
<summary>The Transact-SQL statement is not valid for notifications; for example, a SELECT statement that could not be notified or a non-SELECT statement was executed.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlNotificationSource.System">
|
||
|
<summary>A system-related event occurred. For example, there was an internal error, the server was restarted, or resource pressure caused the invalidation.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlNotificationSource.Timeout">
|
||
|
<summary>The subscription time-out expired.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlNotificationSource.Unknown">
|
||
|
<summary>Used when the source option sent by the server was not recognized by the client.</summary>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlNotificationType">
|
||
|
<summary>Describes the different notification types that can be received by an <see cref="T:Microsoft.Data.SqlClient.OnChangeEventHandler" /> event handler through the <see cref="T:Microsoft.Data.SqlClient.SqlNotificationEventArgs" /> parameter.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlNotificationType> enumeration is referenced by an instance of the <xref:Microsoft.Data.SqlClient.SqlNotificationEventArgs> class. This information is provided when a notification event is fired with the <xref:Microsoft.Data.SqlClient.SqlDependency> class.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlNotificationType.Change">
|
||
|
<summary>Data on the server being monitored changed. Use the <see cref="T:Microsoft.Data.SqlClient.SqlNotificationInfo" /> item to determine the details of the change.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlNotificationType.Subscribe">
|
||
|
<summary>There was a failure to create a notification subscription. Use the <see cref="T:Microsoft.Data.SqlClient.SqlNotificationEventArgs" /> object's <see cref="T:Microsoft.Data.SqlClient.SqlNotificationInfo" /> item to determine the cause of the failure.</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.SqlNotificationType.Unknown">
|
||
|
<summary>Used when the type option sent by the server was not recognized by the client.</summary>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlParameter">
|
||
|
<summary>Represents a parameter to a <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> and optionally its mapping to <see cref="T:System.Data.DataSet" /> columns. This class cannot be inherited. For more information on parameters, see [Configuring parameters](/sql/connect/ado-net/configure-parameters).</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Parameter names are not case sensitive.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> Nameless, also called ordinal, parameters are not supported by the .NET Framework Data Provider for SQL Server.
|
||
|
|
||
|
For more information, along with additional sample code demonstrating how to use parameters, see [Commands and Parameters](/sql/connect/ado-net/commands-parameters).
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates multiple instances of <xref:Microsoft.Data.SqlClient.SqlParameter> through the <xref:Microsoft.Data.SqlClient.SqlParameterCollection> collection within the <xref:Microsoft.Data.SqlClient.SqlDataAdapter>. These parameters are used to select data from the data source and put the data in the <xref:System.Data.DataSet>. This example assumes that a <xref:System.Data.DataSet> and a <xref:Microsoft.Data.SqlClient.SqlDataAdapter> have already been created by using the appropriate schema, commands, and connection. For more information and additional examples on using parameters, see [Retrieving and Modifying Data in ADO.NET](/sql/connect/ado-net/retrieving-modifying-data) and [Configuring parameters](/sql/connect/ado-net/configure-parameters).
|
||
|
|
||
|
[!code-csharp[SqlParameterCollection_Add6](~/../sqlclient/doc/samples/SqlParameterCollection_Add6.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><altmember cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" /><altmember cref="T:Microsoft.Data.SqlClient.SqlCommand" />
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameter.#ctor">
|
||
|
<summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> class.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlParameter> and sets some of its properties.
|
||
|
|
||
|
[!code-csharp[SqlParameter_SqlParameter Example#1](~/../sqlclient/doc/samples/SqlParameter_SqlParameter.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameter.#ctor(System.String,System.Data.SqlDbType)">
|
||
|
<param name="parameterName">The name of the parameter to map.</param><param name="dbType">One of the <see cref="T:System.Data.SqlDbType" /> values.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> class that uses the parameter name and the data type.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The data type and, if appropriate, **Size** and <xref:Microsoft.Data.SqlClient.SqlParameter.Precision%2A> are inferred from the value of the `dbType` parameter.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlParameter> and sets some of its properties.
|
||
|
|
||
|
[!code-csharp[SqlParameter_SqlParameter2 Example#1](~/../sqlclient/doc/samples/SqlParameter_SqlParameter2.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentException">The value supplied in the <paramref name="dbType" /> parameter is an invalid back-end data type.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameter.#ctor(System.String,System.Data.SqlDbType,System.Int32)">
|
||
|
<param name="parameterName">The name of the parameter to map.</param><param name="dbType">One of the <see cref="T:System.Data.SqlDbType" /> values.</param><param name="size">The length of the parameter.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> class that uses the parameter name, the <see cref="T:System.Data.SqlDbType" />, and the size.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The **Size** is inferred from the value of the `dbType` parameter if it is not explicitly set in the `size` parameter.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlParameter> and sets some of its properties.
|
||
|
|
||
|
[!code-csharp[SqlParameter_SqlParameter4 Example#1](~/../sqlclient/doc/samples/SqlParameter_SqlParameter4.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentException">The value supplied in the <paramref name="dbType" /> parameter is an invalid back-end data type.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameter.#ctor(System.String,System.Data.SqlDbType,System.Int32,System.Data.ParameterDirection,System.Boolean,System.Byte,System.Byte,System.String,System.Data.DataRowVersion,System.Object)">
|
||
|
<param name="parameterName">The name of the parameter to map.</param><param name="dbType">One of the <see cref="T:System.Data.SqlDbType" /> values.</param><param name="size">The length of the parameter.</param><param name="direction">One of the <see cref="T:System.Data.ParameterDirection" /> values.</param><param name="isNullable">
|
||
|
<see langword="true" /> if the value of the field can be null; otherwise, <see langword="false" />.</param><param name="precision">The total number of digits to the left and right of the decimal point to which <see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" /> is resolved.</param><param name="scale">The total number of decimal places to which <see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" /> is resolved.</param><param name="sourceColumn">The name of the source column (<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SourceColumn" />) if this <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> is used in a call to <see cref="M:System.Data.Common.DbDataAdapter.Update(System.Data.DataSet)" />.</param><param name="sourceVersion">One of the <see cref="T:System.Data.DataRowVersion" /> values.</param><param name="value">An <see cref="T:System.Object" /> that is the value of the <see cref="T:Microsoft.Data.SqlClient.SqlParameter" />.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> class that uses the parameter name, the type of the parameter, the size of the parameter, a <see cref="T:System.Data.ParameterDirection" />, the precision of the parameter, the scale of the parameter, the source column, a <see cref="T:System.Data.DataRowVersion" /> to use, and the value of the parameter.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The **Size** and <xref:Microsoft.Data.SqlClient.SqlParameter.Precision%2A> are inferred from the value of the `dbType` parameter if they are not explicitly set in the `size` and `precision` parameters.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlParameter> and sets some of its properties.
|
||
|
|
||
|
[!code-csharp[SqlParameter_SqlParameter1 Example#1](~/../sqlclient/doc/samples/SqlParameter_SqlParameter1.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentException">The value supplied in the <paramref name="dbType" /> parameter is an invalid back-end data type.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameter.#ctor(System.String,System.Data.SqlDbType,System.Int32,System.Data.ParameterDirection,System.Byte,System.Byte,System.String,System.Data.DataRowVersion,System.Boolean,System.Object,System.String,System.String,System.String)">
|
||
|
<param name="parameterName">The name of the parameter to map.</param><param name="dbType">One of the <see cref="T:System.Data.SqlDbType" /> values.</param><param name="size">The length of the parameter.</param><param name="direction">One of the <see cref="T:System.Data.ParameterDirection" /> values.</param><param name="precision">The total number of digits to the left and right of the decimal point to which <see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" /> is resolved.</param><param name="scale">The total number of decimal places to which <see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" /> is resolved.</param><param name="sourceColumn">The name of the source column (<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SourceColumn" />) if this <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> is used in a call to <see cref="M:System.Data.Common.DbDataAdapter.Update(System.Data.DataSet)" />>.</param><param name="sourceVersion">One of the <see cref="T:System.Data.DataRowVersion" /> values.</param><param name="sourceColumnNullMapping">
|
||
|
<see langword="true" /> if the source column is nullable; <see langword="false" /> if it is not.</param><param name="value">An <see cref="T:System.Object" /> that is the value of the <see cref="T:Microsoft.Data.SqlClient.SqlParameter" />.</param><param name="xmlSchemaCollectionDatabase">The name of the database where the schema collection for this XML instance is located.</param><param name="xmlSchemaCollectionOwningSchema">The owning relational schema where the schema collection for this XML instance is located.</param><param name="xmlSchemaCollectionName">The name of the schema collection for this parameter.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> class that uses the parameter name, the type of the parameter, the length of the parameter the direction, the precision, the scale, the name of the source column, one of the <see cref="T:System.Data.DataRowVersion" /> values, a Boolean for source column mapping, the value of the <see langword="SqlParameter" />, the name of the database where the schema collection for this XML instance is located, the owning relational schema where the schema collection for this XML instance is located, and the name of the schema collection for this parameter.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlParameter.Size%2A> and <xref:Microsoft.Data.SqlClient.SqlParameter.Precision%2A> are inferred from the value of the `dbType` parameter if they are not explicitly set in the `size` and `precision` parameters.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameter.#ctor(System.String,System.Data.SqlDbType,System.Int32,System.String)">
|
||
|
<param name="parameterName">The name of the parameter to map.</param><param name="dbType">One of the <see cref="T:System.Data.SqlDbType" /> values.</param><param name="size">The length of the parameter.</param><param name="sourceColumn">The name of the source column (<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SourceColumn" />) if this <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> is used in a call to <see cref="M:System.Data.Common.DbDataAdapter.Update(System.Data.DataSet)" />>.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> class that uses the parameter name, the <see cref="T:System.Data.SqlDbType" />, the size, and the source column name.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The **Size** is inferred from the value of the `dbType` parameter if it is not explicitly set in the `size` parameter.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlParameter> and sets some of its properties.
|
||
|
|
||
|
[!code-csharp[SqlParameter_SqlParameter5 Example#1](~/../sqlclient/doc/samples/SqlParameter_SqlParameter5.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentException">The value supplied in the <paramref name="dbType" /> parameter is an invalid back-end data type.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameter.#ctor(System.String,System.Object)">
|
||
|
<param name="parameterName">The name of the parameter to map.</param><param name="value">An <see cref="T:System.Object" /> that is the value of the <see cref="T:Microsoft.Data.SqlClient.SqlParameter" />.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> class that uses the parameter name and a value of the new <see cref="T:Microsoft.Data.SqlClient.SqlParameter" />.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
When you specify an <xref:System.Object> in the `value` parameter, the <xref:Microsoft.Data.SqlClient.SqlParameter.SqlDbType%2A> is inferred from the Microsoft .NET Framework type of the <xref:System.Object>.
|
||
|
|
||
|
Use caution when you use this overload of the <xref:Microsoft.Data.SqlClient.SqlParameter> constructor to specify integer parameter values. Because this overload takes a `value` of type <xref:System.Object>, you must convert the integral value to an <xref:System.Object> type when the value is zero, as the following C# example demonstrates.
|
||
|
|
||
|
```csharp
|
||
|
Parameter = new SqlParameter("@pname", (object)0);
|
||
|
```
|
||
|
|
||
|
If you do not perform this conversion, the compiler assumes that you are trying to call the <xref:Microsoft.Data.SqlClient.SqlParameter.%23ctor(System.String,System.Data.SqlDbType)> constructor overload.
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlParameter> and sets some of its properties.
|
||
|
|
||
|
[!code-csharp[SqlParameter_SqlParameter6 Example#1](~/../sqlclient/doc/samples/SqlParameter_SqlParameter6.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlParameter.CompareInfo">
|
||
|
<summary>Gets or sets the <see cref="T:System.Globalization.CompareInfo" /> object that defines how string comparisons should be performed for this parameter.</summary><value>A <see cref="T:System.Globalization.CompareInfo" /> object that defines string comparison for this parameter.</value><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlParameter.DbType">
|
||
|
<summary>Gets or sets the <see cref="T:System.Data.SqlDbType" /> of the parameter.</summary><value>One of the <see cref="T:System.Data.SqlDbType" /> values. The default is <see langword="NVarChar" />.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlParameter.SqlDbType%2A> and <xref:Microsoft.Data.SqlClient.SqlParameter.DbType%2A> are linked. Therefore, setting the <xref:Microsoft.Data.SqlClient.SqlParameter.DbType%2A> changes the <xref:Microsoft.Data.SqlClient.SqlParameter.SqlDbType%2A> to a supporting <xref:System.Data.SqlDbType>.
|
||
|
|
||
|
For a list of the supported data types, see the appropriate <xref:System.Data.SqlDbType> member. For more information, see [DataAdapter Parameters](/sql/connect/ado-net/dataadapter-parameters).
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlParameter> and sets some of its properties.
|
||
|
|
||
|
[!code-csharp[SqlParameter_IsNullable Example#1](~/../sqlclient/doc/samples/SqlParameter_IsNullable.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlParameter.Direction">
|
||
|
<summary>Gets or sets a value that indicates whether the parameter is input-only, output-only, bidirectional, or a stored procedure return value parameter.</summary><value>One of the <see cref="T:System.Data.ParameterDirection" /> values. The default is <see langword="Input" />.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
If the <xref:System.Data.ParameterDirection> is output, and execution of the associated <xref:Microsoft.Data.SqlClient.SqlCommand> does not return a value, the <xref:Microsoft.Data.SqlClient.SqlParameter> contains a null value.
|
||
|
|
||
|
`Output`, `InputOut`, and `ReturnValue` parameters returned by calling <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteReader%2A> cannot be accessed until you close the <xref:Microsoft.Data.SqlClient.SqlDataReader>.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlParameter> and sets some of its properties.
|
||
|
|
||
|
[Commands and Parameters](/sql/connect/ado-net/commands-parameters)
|
||
|
|
||
|
[DataAdapter Parameters](/sql/connect/ado-net/dataadapter-parameters)
|
||
|
|
||
|
[SQL Server and ADO.NET](/sql/connect/ado-net/sql/)
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentException">The property was not set to one of the valid <see cref="T:System.Data.ParameterDirection" /> values.</exception>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlParameter.ForceColumnEncryption">
|
||
|
<summary>Enforces encryption of a parameter when using <see href="https://docs.microsoft.com/sql/relational-databases/security/encryption/always-encrypted-database-engine">Always Encrypted</see>. If SQL Server informs the driver that the parameter does not need to be encrypted, the query using the parameter will fail. This property provides additional protection against security attacks that involve a compromised SQL Server providing incorrect encryption metadata to the client, which may lead to data disclosure.</summary><value>
|
||
|
<see langword="true" /> if the parameter has a force column encryption; otherwise, <see langword="false" />.</value><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlParameter.IsNullable">
|
||
|
<summary>Gets or sets a value that indicates whether the parameter accepts null values. <see cref="P:Microsoft.Data.SqlClient.SqlParameter.IsNullable" /> is not used to validate the parameter's value and will not prevent sending or receiving a null value when executing a command.</summary><value>
|
||
|
<see langword="true" /> if null values are accepted; otherwise, <see langword="false" />. The default is <see langword="false" />.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Null values are handled using the <xref:System.DBNull> class.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlParameter> and sets some of its properties.
|
||
|
|
||
|
[!code-csharp[SqlParameter#2](~/../sqlclient/doc/samples/SqlParameter.cs#2)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlParameter.LocaleId">
|
||
|
<summary>Gets or sets the locale identifier that determines conventions and language for a particular region.</summary><value>The locale identifier associated with the parameter.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The locale identifies conventions and language for a particular geographical region. The codepage used to encode a specific string (the character set) is based on the locale used by that string or the environment that produced it. This property sets (for input parameters) or gets (for output parameters) the locale to be attached to a string when exchanging data with the server. This property is typically used together with the <xref:Microsoft.Data.SqlClient.SqlParameter.CompareInfo%2A> property.
|
||
|
|
||
|
```csharp
|
||
|
static void CreateSqlParameterLocaleId(){
|
||
|
SqlParameter parameter = new SqlParameter("pName", SqlDbType.VarChar);
|
||
|
parameter.LocaleId = 1033; // English - United States
|
||
|
}
|
||
|
```
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlParameter.Offset">
|
||
|
<summary>Gets or sets the offset to the <see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" /> property.</summary><value>The offset to the <see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />. The default is 0.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The `Offset` property is used for client-side chunking of binary and string data. For example, in order to insert 10MB of text into a column on a server, a user might execute 10 parameterized inserts of 1MB chunks, shifting the value of `Offset` on each iteration by 1MB.
|
||
|
|
||
|
`Offset` specifies the number of bytes for binary types, and the number of characters for strings. The count for strings does not include the terminating character.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlParameter> and sets some of its properties.
|
||
|
|
||
|
[!code-csharp[SqlParameter#3](~/../sqlclient/doc/samples/SqlParameter.cs#3)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlParameter.ParameterName">
|
||
|
<summary>Gets or sets the name of the <see cref="T:Microsoft.Data.SqlClient.SqlParameter" />.</summary><value>The name of the <see cref="T:Microsoft.Data.SqlClient.SqlParameter" />. The default is an empty string.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlParameter.ParameterName%2A> is specified in the form @paramname. You must set <xref:Microsoft.Data.SqlClient.SqlParameter.ParameterName%2A> before executing a <xref:Microsoft.Data.SqlClient.SqlCommand> that relies on parameters.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlParameter> and sets some of its properties.
|
||
|
|
||
|
[!code-csharp[SqlParameter_ParameterName Example#1](~/../sqlclient/doc/samples/SqlParameter_ParameterName.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlParameter.Precision">
|
||
|
<summary>Gets or sets the maximum number of digits used to represent the <see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" /> property.</summary><value>The maximum number of digits used to represent the <see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" /> property. The default value is 0. This indicates that the data provider sets the precision for <see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" />.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlParameter.Precision%2A> property is used by parameters that have a <xref:System.Data.SqlDbType> of `Decimal`.
|
||
|
|
||
|
You do not need to specify values for the <xref:Microsoft.Data.SqlClient.SqlParameter.Precision%2A> and <xref:Microsoft.Data.SqlClient.SqlParameter.Scale%2A> properties for input parameters, as they can be inferred from the parameter value. `Precision` and `Scale` are required for output parameters and for scenarios where you need to specify complete metadata for a parameter without indicating a value, such as specifying a null value with a specific precision and scale.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> Use of this property to coerce data passed to the database is not supported. To round, truncate, or otherwise coerce data before passing it to the database, use the <xref:System.Math> class that is part of the `System` namespace prior to assigning a value to the parameter's `Value` property.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> Microsoft .NET Framework data providers that are included with the .NET Framework version 1.0 do not verify the <xref:Microsoft.Data.SqlClient.SqlParameter.Precision%2A> or <xref:Microsoft.Data.SqlClient.SqlParameter.Scale%2A> of <xref:System.Decimal> parameter values. This can cause truncated data being inserted at the data source. If you are using .NET Framework version 1.0, validate the <xref:Microsoft.Data.SqlClient.SqlParameter.Precision%2A> and <xref:Microsoft.Data.SqlClient.SqlParameter.Scale%2A> of <xref:System.Decimal> values before setting the parameter value. When you use .NET Framework version 1.1 or a later version, an exception is thrown if a <xref:System.Decimal> parameter value is set with an invalid <xref:Microsoft.Data.SqlClient.SqlParameter.Precision%2A>. <xref:Microsoft.Data.SqlClient.SqlParameter.Scale%2A> values that exceed the <xref:System.Decimal> parameter scale are still truncated.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlParameter> and sets some of its properties.
|
||
|
|
||
|
[!code-csharp[SqlParameter_Precision Example#1](~/../sqlclient/doc/samples/SqlParameter_Precision.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlParameter.Scale">
|
||
|
<summary>Gets or sets the number of decimal places to which <see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" /> is resolved.</summary><value>The number of decimal places to which <see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" /> is resolved. The default is 0.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlParameter.Scale%2A> property is used by parameters that have a <xref:System.Data.SqlDbType> of `Decimal`.
|
||
|
|
||
|
> [!WARNING]
|
||
|
> Data may be truncated if the <xref:Microsoft.Data.SqlClient.SqlParameter.Scale%2A> property is not explicitly specified and the data on the server does not fit in scale 0 (the default).
|
||
|
|
||
|
You do not need to specify values for the <xref:Microsoft.Data.SqlClient.SqlParameter.Precision%2A> and <xref:Microsoft.Data.SqlClient.SqlParameter.Scale%2A> properties for input parameters, as they can be inferred from the parameter value. `Precision` and `Scale` are required for output parameters and for scenarios where you need to specify complete metadata for a parameter without indicating a value, such as specifying a null value with a specific precision and scale.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> Use of this property to coerce data passed to the database is not supported. To round, truncate, or otherwise coerce data before passing it to the database, use the <xref:System.Math> class that is part of the `System` namespace prior to assigning a value to the parameter's `Value` property.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> .NET Framework data providers that are included with the .NET Framework version 1.0 do not verify the <xref:Microsoft.Data.SqlClient.SqlParameter.Precision%2A> or <xref:Microsoft.Data.SqlClient.SqlParameter.Scale%2A> of <xref:System.Decimal> parameter values. This can cause truncated data to be inserted at the data source. If you are using .NET Framework version 1.0, validate the <xref:Microsoft.Data.SqlClient.SqlParameter.Precision%2A> and <xref:Microsoft.Data.SqlClient.SqlParameter> of <xref:System.Decimal> values before setting the parameter value. <xref:Microsoft.Data.SqlClient.SqlParameter.Scale%2A> values that exceed the <xref:System.Decimal> parameter scale are still truncated.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlParameter> and sets some of its properties.
|
||
|
|
||
|
[!code-csharp[SqlParameter#4](~/../sqlclient/doc/samples/SqlParameter.cs#4)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlParameter.Size">
|
||
|
<summary>Gets or sets the maximum size, in bytes, of the data within the column.</summary><value>The maximum size, in bytes, of the data within the column. The default value is inferred from the parameter value.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Return values are not affected by this property; return parameters from stored procedures are always fixed-size integers.
|
||
|
|
||
|
For output parameters with a variable length type (nvarchar, for example), the size of the parameter defines the size of the buffer holding the output parameter. The output parameter can be truncated to a size specified with <xref:Microsoft.Data.SqlClient.SqlParameter.Size%2A>. For character types, the size specified with <xref:Microsoft.Data.SqlClient.SqlParameter.Size%2A> is in characters.
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlParameter.Size%2A> property is used for binary and string types. For parameters of type `SqlType.String`, `Size` means length in Unicode characters. For parameters of type `SqlType.Xml`, `Size` is ignored.
|
||
|
|
||
|
For nonstring data types and ANSI string data, the <xref:Microsoft.Data.SqlClient.SqlParameter.Size%2A> property refers to the number of bytes. For Unicode string data, <xref:Microsoft.Data.SqlClient.SqlParameter.Size%2A> refers to the number of characters. The count for strings does not include the terminating character.
|
||
|
|
||
|
For variable-length data types, <xref:Microsoft.Data.SqlClient.SqlParameter.Size%2A> describes the maximum amount of data to transmit to the server. For example, for a Unicode string value, <xref:Microsoft.Data.SqlClient.SqlParameter.Size%2A> could be used to limit the amount of data sent to the server to the first one hundred characters.
|
||
|
|
||
|
If not explicitly set, the size is inferred from the actual size of the specified parameter value.
|
||
|
|
||
|
If the fractional part of the parameter value is greater than the size, then the value will be truncated to match the size.
|
||
|
|
||
|
For fixed length data types, the value of <xref:Microsoft.Data.SqlClient.SqlParameter.Size%2A> is ignored. It can be retrieved for informational purposes, and returns the maximum amount of bytes the provider uses when transmitting the value of the parameter to the server.
|
||
|
|
||
|
For information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlParameter> and sets some of its properties.
|
||
|
|
||
|
[!code-csharp[SqlParameter#5](~/../sqlclient/doc/samples/SqlParameter.cs#5)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlParameter.SourceColumn">
|
||
|
<summary>Gets or sets the name of the source column mapped to the <see cref="T:System.Data.DataSet" /> and used for loading or returning the <see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" /></summary><value>The name of the source column mapped to the <see cref="T:System.Data.DataSet" />. The default is an empty string.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
When <xref:Microsoft.Data.SqlClient.SqlParameter.SourceColumn%2A> is set to anything other than an empty string, the value of the parameter is retrieved from the column with the <xref:Microsoft.Data.SqlClient.SqlParameter.SourceColumn%2A> name. If <xref:Microsoft.Data.SqlClient.SqlParameter.Direction%2A> is set to `Input`, the value is taken from the <xref:System.Data.DataSet>. If <xref:Microsoft.Data.SqlClient.SqlParameter.Direction%2A> is set to `Output`, the value is taken from the data source. A <xref:Microsoft.Data.SqlClient.SqlParameter.Direction%2A> of `InputOutput` is a combination of both.
|
||
|
|
||
|
For more information about how to use the <xref:Microsoft.Data.SqlClient.SqlParameter.SourceColumn%2A> property, see [DataAdapter Parameters](/sql/connect/ado-net/dataadapter-parameters) and [Updating Data Sources with DataAdapters](/sql/connect/ado-net/update-data-sources-with-dataadapters).
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlParameter> and sets some of its properties.
|
||
|
|
||
|
[!code-csharp[SqlParameter#6](~/../sqlclient/doc/samples/SqlParameter.cs#6)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlParameter.SourceColumnNullMapping">
|
||
|
<summary>Sets or gets a value which indicates whether the source column is nullable. This allows <see cref="T:Microsoft.Data.SqlClient.SqlCommandBuilder" /> to correctly generate Update statements for nullable columns.</summary><value>
|
||
|
<see langword="true" /> if the source column is nullable; <see langword="false" /> if it is not.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
<xref:Microsoft.Data.SqlClient.SqlParameter.SourceColumnNullMapping%2A> is used by the <xref:Microsoft.Data.SqlClient.SqlCommandBuilder> to correctly generate update commands when dealing with nullable columns. Generally, use of <xref:Microsoft.Data.SqlClient.SqlParameter.SourceColumnNullMapping%2A> is limited to developers inheriting from <xref:Microsoft.Data.SqlClient.SqlCommandBuilder>.
|
||
|
|
||
|
<xref:System.Data.Common.DbCommandBuilder> uses this property to determine whether the source column is nullable, and sets this property to `true` if it is nullable, and `false` if it is not. When <xref:Microsoft.Data.SqlClient.SqlCommandBuilder> is generating its Update statement, it examines the <xref:Microsoft.Data.SqlClient.SqlParameter.SourceColumnNullMapping%2A> for each parameter. If the property is `true`, <xref:Microsoft.Data.SqlClient.SqlCommandBuilder> generates a WHERE clauses like the following (in this query expression, "FieldName" represents the name of the field):
|
||
|
|
||
|
```
|
||
|
((@IsNull_FieldName = 1 AND FieldName IS NULL) OR
|
||
|
(FieldName = @Original_FieldName))
|
||
|
```
|
||
|
|
||
|
If <xref:Microsoft.Data.SqlClient.SqlParameter.SourceColumnNullMapping%2A> for the field is false, <xref:Microsoft.Data.SqlClient.SqlCommandBuilder> generates the following WHERE clause:
|
||
|
|
||
|
```
|
||
|
FieldName = @OriginalFieldName
|
||
|
```
|
||
|
|
||
|
In addition, @IsNull_FieldName contains 1 if the source field contains null, and 0 if it does not. This mechanism allows for a performance optimization in SQL Server, and provides for common code that works across multiple providers.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlParameter.SourceVersion">
|
||
|
<summary>Gets or sets the <see cref="T:System.Data.DataRowVersion" /> to use when you load <see cref="P:Microsoft.Data.SqlClient.SqlParameter.Value" /></summary><value>One of the <see cref="T:System.Data.DataRowVersion" /> values. The default is <see langword="Current" />.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This property is used by the `SqlDataAdapter.UpdateCommand` during an update to determine whether the original or current value is used for a parameter value. This lets primary keys be updated. This property is set to the version of the <xref:System.Data.DataRow> used by the `DataRow.Item` property, or one of the `DataRow.GetChildRows` methods of the <xref:System.Data.DataRow> object.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlParameter> and sets some of its properties.
|
||
|
|
||
|
[!code-csharp[SqlParameter#7](~/../sqlclient/doc/samples/SqlParameter.cs#7)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlParameter.SqlDbType">
|
||
|
<summary>Gets or sets the <see cref="T:System.Data.SqlDbType" /> of the parameter.</summary><value>One of the <see cref="T:System.Data.SqlDbType" /> values. The default is <see langword="NVarChar" />.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlParameter.SqlDbType%2A> and <xref:Microsoft.Data.SqlClient.SqlParameter.DbType%2A> are linked. Therefore, setting the <xref:Microsoft.Data.SqlClient.SqlParameter.DbType%2A> changes the <xref:Microsoft.Data.SqlClient.SqlParameter.SqlDbType%2A> to a supporting <xref:System.Data.SqlDbType>.
|
||
|
|
||
|
For a list of the supported data types, see the appropriate <xref:System.Data.SqlDbType> member. For more information, see [DataAdapter Parameters](/sql/connect/ado-net/dataadapter-parameters).
|
||
|
|
||
|
For information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlParameter.SqlValue">
|
||
|
<summary>Gets or sets the value of the parameter as an SQL type.</summary><value>An <see cref="T:System.Object" /> that is the value of the parameter, using SQL types. The default value is null.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
For input parameters, the value is bound to the <xref:Microsoft.Data.SqlClient.SqlCommand> that is sent to the server. For output and return value parameters, the value is set on completion of the <xref:Microsoft.Data.SqlClient.SqlCommand> and after the <xref:Microsoft.Data.SqlClient.SqlDataReader> is closed.
|
||
|
|
||
|
This property can be set to null or <xref:System.DBNull.Value?displayProperty=nameWithType>. Use <xref:System.DBNull.Value?displayProperty=nameWithType> to send a NULL value as the value of the parameter. Use null or do not set <xref:Microsoft.Data.SqlClient.SqlParameter.SqlValue%2A?displayProperty=nameWithType> to use the default value for the parameter.
|
||
|
|
||
|
If the application specifies the database type, the bound value is converted to that type when the provider sends the data to the server. The provider tries to convert any type of value if it supports the <xref:System.IConvertible> interface. Conversion errors may result if the specified type is not compatible with the value.
|
||
|
|
||
|
Both the <xref:Microsoft.Data.SqlClient.SqlParameter.DbType%2A> and <xref:Microsoft.Data.SqlClient.SqlParameter.SqlDbType%2A> properties can be inferred by setting the <xref:Microsoft.Data.SqlClient.SqlParameter.Value%2A?displayProperty=nameWithType>.
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlParameter.Value%2A?displayProperty=nameWithType> property is overwritten by `SqlDataAdapter.UpdateCommand`.
|
||
|
|
||
|
Use the <xref:Microsoft.Data.SqlClient.SqlParameter.Value%2A?displayProperty=nameWithType> property to return parameter values as common language runtime (CLR) types.
|
||
|
|
||
|
For information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlParameter.TypeName">
|
||
|
<summary>Gets or sets the type name for a table-valued parameter.</summary><value>The type name of the specified table-valued parameter.</value><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlParameter.UdtTypeName">
|
||
|
<summary>Gets or sets a <see langword="string" /> that represents a user-defined type as a parameter.</summary><value>A <see langword="string" /> that represents the fully qualified name of a user-defined type in the database.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
For a sample demonstrating <xref:Microsoft.Data.SqlClient.SqlParameter.UdtTypeName%2A>, see [Retrieving UDT Data](https://msdn.microsoft.com/library/ms131080.aspx).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlParameter.Value">
|
||
|
<summary>Gets or sets the value of the parameter.</summary><value>An <see cref="T:System.Object" /> that is the value of the parameter. The default value is null.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
For input parameters, the value is bound to the <xref:Microsoft.Data.SqlClient.SqlCommand> that is sent to the server. For output and return value parameters, the value is set on completion of the <xref:Microsoft.Data.SqlClient.SqlCommand> and after the <xref:Microsoft.Data.SqlClient.SqlDataReader> is closed.
|
||
|
|
||
|
This property can be set to `null` or <xref:System.DBNull.Value?displayProperty=nameWithType>. Use <xref:System.DBNull.Value?displayProperty=nameWithType> to send a NULL value as the value of the parameter. Use `null` or do not set <xref:Microsoft.Data.SqlClient.SqlParameter.Value%2A> to use the default value for the parameter.
|
||
|
|
||
|
An exception is thrown if non-Unicode XML data is passed as a string.
|
||
|
|
||
|
If the application specifies the database type, the bound value is converted to that type when the provider sends the data to the server. The provider tries to convert any type of value if it supports the <xref:System.IConvertible> interface. Conversion errors may result if the specified type is not compatible with the value.
|
||
|
|
||
|
Both the <xref:Microsoft.Data.SqlClient.SqlParameter.DbType%2A> and <xref:Microsoft.Data.SqlClient.SqlParameter.SqlDbType%2A> properties can be inferred by setting the Value.
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlParameter.Value%2A> property is overwritten by `SqlDataAdapter.UpdateCommand`.
|
||
|
|
||
|
For information about streaming, see [SqlClient Streaming Support](/sql/connect/ado-net/sqlclient-streaming-support).
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlParameter> and sets some of its properties.
|
||
|
|
||
|
[!code-csharp[SqlParameter#8](~/../sqlclient/doc/samples/SqlParameter.cs#8)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlParameter.XmlSchemaCollectionDatabase">
|
||
|
<summary>Gets the name of the database where the schema collection for this XML instance is located.</summary><value>The name of the database where the schema collection for this XML instance is located.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This value is null (`Nothing` in Microsoft Visual Basic) if the collection is defined within the current database. It is also null if there is no schema collection, in which case <xref:Microsoft.Data.SqlClient.SqlParameter.XmlSchemaCollectionName%2A> and <xref:Microsoft.Data.SqlClient.SqlParameter.XmlSchemaCollectionOwningSchema%2A> are also null.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlParameter.XmlSchemaCollectionName">
|
||
|
<summary>Gets the name of the schema collection for this XML instance.</summary><value>The name of the schema collection for this XML instance.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This value is null (`Nothing` in Microsoft Visual Basic) if there is no associated schema collection. If the value is null, then <xref:Microsoft.Data.SqlClient.SqlParameter.XmlSchemaCollectionDatabase%2A> and <xref:Microsoft.Data.SqlClient.SqlParameter.XmlSchemaCollectionOwningSchema%2A> are also null.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlParameter.XmlSchemaCollectionOwningSchema">
|
||
|
<summary>The owning relational schema where the schema collection for this XML instance is located.</summary><value>The owning relational schema for this XML instance.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This value is null (`Nothing` in Microsoft Visual Basic) if the collection is defined within the current database. It is also null if there is no schema collection, in which case <xref:Microsoft.Data.SqlClient.SqlParameter.XmlSchemaCollectionDatabase%2A> and <xref:Microsoft.Data.SqlClient.SqlParameter.XmlSchemaCollectionName%2A> are also null.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameter.ResetDbType">
|
||
|
<summary>Resets the type associated with this <see cref="T:Microsoft.Data.SqlClient.SqlParameter" />.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
When executing a command that includes parameter values, code can either set the type of a parameter explicitly, or the parameter can infer its type from its value. Calling this method resets the parameter so that it can again infer its type from the value passed in the parameter. Calling this method affects both the <xref:Microsoft.Data.SqlClient.SqlParameter.DbType%2A> and <xref:Microsoft.Data.SqlClient.SqlParameter.SqlDbType%2A> properties of the <xref:Microsoft.Data.SqlClient.SqlParameter>.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameter.ResetSqlDbType">
|
||
|
<summary>Resets the type associated with this <see cref="T:Microsoft.Data.SqlClient.SqlParameter" />.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
When executing a command that includes parameter values, code can either set the type of a parameter explicitly, or the parameter can infer its type from its value. Calling this method resets the parameter so that it can again infer its type from the value passed in the parameter. Calling this method affects both the <xref:Microsoft.Data.SqlClient.SqlParameter.DbType%2A> and <xref:Microsoft.Data.SqlClient.SqlParameter.SqlDbType%2A> properties of the <xref:Microsoft.Data.SqlClient.SqlParameter>.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameter.ToString">
|
||
|
<summary>Gets a string that contains the <see cref="P:Microsoft.Data.SqlClient.SqlParameter.ParameterName" />.</summary><returns>A string that contains the <see cref="P:Microsoft.Data.SqlClient.SqlParameter.ParameterName" />.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlParameterCollection">
|
||
|
<summary>Represents a collection of parameters associated with a <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> and their respective mappings to columns in a <see cref="T:System.Data.DataSet" />. This class cannot be inherited.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
If the command contains an ad hoc SQL statement, as opposed to a stored-procedure name, the number of the parameters in the collection must be equal to the number of parameter placeholders within the command text, or SQL Server raises an error. With a stored procedure, all the parameters declared in the stored procedure without a default value must be provided. Parameters declared with a default value are optional. This lets you specify a value other than the default.
|
||
|
|
||
|
For more information with additional sample code demonstrating how to use parameters, see [Commands and Parameters](/sql/connect/ado-net/commands-parameters).
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates multiple instances of <xref:Microsoft.Data.SqlClient.SqlParameter> through the <xref:Microsoft.Data.SqlClient.SqlParameterCollection> collection. The parameters are used to select data within the data source and populate the <xref:System.Data.DataSet>. This code assumes that a <xref:System.Data.DataSet> and a <xref:Microsoft.Data.SqlClient.SqlDataAdapter> have already been created with the appropriate schema, commands, and connection.
|
||
|
|
||
|
[!code-csharp[SqlParameterCollection_Add6 Example#1](~/../sqlclient/doc/samples/SqlParameterCollection_Add6.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlParameterCollection.Count">
|
||
|
<summary>Returns an Integer that contains the number of elements in the <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" />. Read-only.</summary><value>The number of elements in the <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" /> as an Integer.</value><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlParameterCollection.IsFixedSize">
|
||
|
<summary>Gets a value that indicates whether the <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" /> has a fixed size.</summary><value>
|
||
|
<see langword="true" /> if the <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" /> has a fixed size; otherwise, <see langword="false" />.</value><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlParameterCollection.IsReadOnly">
|
||
|
<summary>Gets a value that indicates whether the <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" /> is read-only.</summary><value>
|
||
|
<see langword="true" /> if the <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" /> is read-only; otherwise, <see langword="false" />.</value><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlParameterCollection.Item(System.Int32)">
|
||
|
<param name="index">The zero-based index of the parameter to retrieve.</param><summary>Gets the <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> at the specified index.</summary><value>The <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> at the specified index.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Examples
|
||
|
The following example demonstrates creating <xref:Microsoft.Data.SqlClient.SqlParameter> objects to supply an input parameter to a stored procedure that returns results in an output parameter. The code iterates through the items in the <xref:Microsoft.Data.SqlClient.SqlParameterCollection> and displays some parameter properties in the console window. This example assumes a valid connection string to the **AdventureWorks** sample database on an instance of SQL Server.
|
||
|
|
||
|
[!code-csharp[SqlParameterCollection_Count Example#1](~/../sqlclient/doc/samples/SqlParameterCollection_Count.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.IndexOutOfRangeException">The specified index does not exist.</exception>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlParameterCollection.Item(System.String)">
|
||
|
<param name="parameterName">The name of the parameter to retrieve.</param><summary>Gets the <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> with the specified name.</summary><value>The <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> with the specified name.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The `parameterName` is used to look up the index value in the underlying <xref:Microsoft.Data.SqlClient.SqlParameterCollection>. If the `parameterName` is not valid, an <xref:System.IndexOutOfRangeException> will be thrown.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.IndexOutOfRangeException">The specified <paramref name="parameterName" /> is not valid.</exception>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlParameterCollection.SyncRoot">
|
||
|
<summary>Gets an object that can be used to synchronize access to the <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" />.</summary><value>An object that can be used to synchronize access to the <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" />.</value><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameterCollection.Add(Microsoft.Data.SqlClient.SqlParameter)">
|
||
|
<param name="value">The <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> to add to the collection.</param><summary>Adds the specified <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> object to the <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" />.</summary><returns>A new <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> object.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Examples
|
||
|
[!code-csharp[SqlParameterCollection_Add Example#1](~/../sqlclient/doc/samples/SqlParameterCollection_Add.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentException">The <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> specified in the <paramref name="value" /> parameter is already added to this or another <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" />.</exception><exception cref="T:System.InvalidCastException">The parameter passed was not a <see cref="T:Microsoft.Data.SqlClient.SqlParameter" />.</exception><exception cref="T:System.ArgumentNullException">The <paramref name="value" /> parameter is null.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameterCollection.Add(System.Object)">
|
||
|
<param name="value">An <see cref="T:System.Object" />.</param><summary>Adds the specified <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> object to the <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" />.</summary><returns>The index of the new <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> object.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameterCollection.Add(System.String,System.Data.SqlDbType)">
|
||
|
<param name="parameterName">The name of the parameter.</param><param name="sqlDbType">One of the <see cref="T:System.Data.SqlDbType" /> values.</param><summary>Adds a <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> to the <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" /> given the parameter name and the data type.</summary><returns>A new <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> object.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Examples
|
||
|
[!code-csharp[SqlParameterCollection_Add3 Example#1](~/../sqlclient/doc/samples/SqlParameterCollection_Add3.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameterCollection.Add(System.String,System.Data.SqlDbType,System.Int32)">
|
||
|
<param name="parameterName">The name of the parameter.</param><param name="sqlDbType">The <see cref="T:System.Data.SqlDbType" /> of the <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> to add to the collection.</param><param name="size">The size as an <see cref="T:System.Int32" />.</param><summary>Adds a <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> to the <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" />, given the specified parameter name, <see cref="T:System.Data.SqlDbType" /> and size.</summary><returns>A new <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> object.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This overload is useful when you are adding a parameter of a variable-length data type such as `varchar` or `binary`.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
[!code-csharp[SqlParameterCollection_Add1 Example#1](~/../sqlclient/doc/samples/SqlParameterCollection_Add1.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameterCollection.Add(System.String,System.Data.SqlDbType,System.Int32,System.String)">
|
||
|
<param name="parameterName">The name of the parameter.</param><param name="sqlDbType">One of the <see cref="T:System.Data.SqlDbType" /> values.</param><param name="size">The column length.</param><param name="sourceColumn">The name of the source column (<see cref="P:Microsoft.Data.SqlClient.SqlParameter.SourceColumn" />) if this <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> is used in a call to <see cref="M:System.Data.Common.DbDataAdapter.Update(System.Data.DataSet)" />.</param><summary>Adds a <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> to the <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" /> with the parameter name, the data type, and the column length.</summary><returns>A new <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> object.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Examples
|
||
|
[!code-csharp[SqlParameterCollection_Add5 Example#1](~/../sqlclient/doc/samples/SqlParameterCollection_Add5.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameterCollection.AddRange(Microsoft.Data.SqlClient.SqlParameter[])">
|
||
|
<param name="values">The <see cref="T:System.Array" /> values to add.</param><summary>Adds an array of values to the end of the <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" />.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameterCollection.AddRange(System.Array)">
|
||
|
<param name="values">The <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> values to add.</param><summary>Adds an array of <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> values to the end of the <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" />.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameterCollection.AddWithValue(System.String,System.Object)">
|
||
|
<param name="parameterName">The name of the parameter.</param><param name="value">The value to be added. Use <see cref="F:System.DBNull.Value" /> instead of null, to indicate a null value.</param><summary>Adds a value to the end of the <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" />.</summary><returns>A <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> object.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
<xref:Microsoft.Data.SqlClient.SqlParameterCollection.AddWithValue%2A> replaces the `SqlParameterCollection.Add` method that takes a <xref:System.String> and an <xref:System.Object>. The overload of `Add` that takes a string and an object was deprecated because of possible ambiguity with the `SqlParameterCollection.Add` overload that takes a <xref:System.String> and a <xref:System.Data.SqlDbType> enumeration value where passing an integer with the string could be interpreted as being either the parameter value or the corresponding <xref:System.Data.SqlDbType> value. Use <xref:Microsoft.Data.SqlClient.SqlParameterCollection.AddWithValue%2A> whenever you want to add a parameter by specifying its name and value.
|
||
|
|
||
|
For <xref:System.Data.SqlDbType>`Xml` enumeration values, you can use a string, an XML value, an <xref:System.Xml.XmlReader> derived type instance, or a <xref:System.Data.SqlTypes.SqlXml> object.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example demonstrates how to use the `AddWithValue` method.
|
||
|
|
||
|
[!code-csharp[SqlParameterCollection_AddWithValue#1](~/../sqlclient/doc/samples/SqlParameterCollection_AddWithValue.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameterCollection.Clear">
|
||
|
<summary>Removes all the <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> objects from the <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" />.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameterCollection.Contains(Microsoft.Data.SqlClient.SqlParameter)">
|
||
|
<param name="value">The <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> value.</param><summary>Determines whether the specified <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> is in this <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" />.</summary><returns>
|
||
|
<see langword="true" /> if the <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" /> contains the value; otherwise, <see langword="false" />.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameterCollection.Contains(System.Object)">
|
||
|
<param name="value">The <see cref="T:System.Object" /> value.</param><summary>Determines whether the specified <see cref="T:System.Object" /> is in this <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" />.</summary><returns>
|
||
|
<see langword="true" /> if the <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" /> contains the value; otherwise, <see langword="false" />.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameterCollection.Contains(System.String)">
|
||
|
<param name="value">The <see cref="T:System.String" /> value.</param><summary>Determines whether the specified parameter name is in this <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" />.</summary><returns>
|
||
|
<see langword="true" /> if the <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" /> contains the value; otherwise, <see langword="false" />.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameterCollection.CopyTo(System.Array,System.Int32)">
|
||
|
<param name="array">The one-dimensional <see cref="T:System.Array" /> that is the destination of the elements copied from the current <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" />.</param><param name="index">A 32-bit integer that represents the index in the <see cref="T:System.Array" /> at which copying starts.</param><summary>Copies all the elements of the current <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" /> to the specified one-dimensional <see cref="T:System.Array" /> starting at the specified destination <see cref="T:System.Array" /> index.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameterCollection.CopyTo(Microsoft.Data.SqlClient.SqlParameter[],System.Int32)">
|
||
|
<param name="array">The <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" /> that is the destination of the elements copied from the current <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" />.</param><param name="index">A 32-bit integer that represents the index in the <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" /> at which copying starts.</param><summary>Copies all the elements of the current <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" /> to the specified <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" /> starting at the specified destination index.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameterCollection.GetEnumerator">
|
||
|
<summary>Returns an enumerator that iterates through the <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" />.</summary><returns>An <see cref="T:System.Collections.IEnumerator" /> for the <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" />.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameterCollection.GetParameter(System.Int32)">
|
||
|
<param name="index">To be added.</param><summary>To be added.</summary><returns>To be added.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameterCollection.GetParameter(System.String)">
|
||
|
<param name="parameterName">To be added.</param><summary>To be added.</summary><returns>To be added.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameterCollection.IndexOf(Microsoft.Data.SqlClient.SqlParameter)">
|
||
|
<param name="value">The <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> to find.</param><summary>Gets the location of the specified <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> within the collection.</summary><returns>The zero-based location of the specified <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> that is a <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> within the collection. Returns -1 when the object does not exist in the <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" />.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameterCollection.IndexOf(System.Object)">
|
||
|
<param name="value">The <see cref="T:System.Object" /> to find.</param><summary>Gets the location of the specified <see cref="T:System.Object" /> within the collection.</summary><returns>The zero-based location of the specified <see cref="T:System.Object" /> that is a <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> within the collection. Returns -1 when the object does not exist in the <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" />.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameterCollection.IndexOf(System.String)">
|
||
|
<param name="parameterName">The case-sensitive name of the <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> to find.</param><summary>Gets the location of the specified <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> with the specified name.</summary><returns>The zero-based location of the specified <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> with the specified case-sensitive name. Returns -1 when the object does not exist in the <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" />.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameterCollection.Insert(System.Int32,Microsoft.Data.SqlClient.SqlParameter)">
|
||
|
<param name="index">The zero-based index at which value should be inserted.</param><param name="value">A <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> object to be inserted in the <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" />.</param><summary>Inserts a <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> object into the <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" /> at the specified index.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameterCollection.Insert(System.Int32,System.Object)">
|
||
|
<param name="index">The zero-based index at which value should be inserted.</param><param name="value">An <see cref="T:System.Object" /> to be inserted in the <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" />.</param><summary>Inserts an <see cref="T:System.Object" /> into the <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" /> at the specified index.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameterCollection.Remove(Microsoft.Data.SqlClient.SqlParameter)">
|
||
|
<param name="value">A <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> object to remove from the collection.</param><summary>Removes the specified <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> from the collection.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Examples
|
||
|
The following example searches for a <xref:Microsoft.Data.SqlClient.SqlParameter> object in a <xref:Microsoft.Data.SqlClient.SqlParameterCollection> collection. If the parameter exists, the example removes it. This example assumes that a <xref:Microsoft.Data.SqlClient.SqlParameterCollection> collection has already been created by a <xref:Microsoft.Data.SqlClient.SqlCommand>.
|
||
|
|
||
|
[!code-csharp[SqlParameterCollection_Remove Example#1](~/../sqlclient/doc/samples/SqlParameterCollection_Remove.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.InvalidCastException">The parameter is not a <see cref="T:Microsoft.Data.SqlClient.SqlParameter" />.</exception><exception cref="T:System.SystemException">The parameter does not exist in the collection.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameterCollection.Remove(System.Object)">
|
||
|
<param name="value">The object to remove from the collection.</param><summary>Removes the specified <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> from the collection.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameterCollection.RemoveAt(System.Int32)">
|
||
|
<param name="index">The zero-based index of the <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> object to remove.</param><summary>Removes the <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> from the <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" /> at the specified index.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameterCollection.RemoveAt(System.String)">
|
||
|
<param name="parameterName">The name of the <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> to remove.</param><summary>Removes the <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> from the <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" /> at the specified parameter name.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameterCollection.SetParameter(System.Int32,System.Data.Common.DbParameter)">
|
||
|
<param name="index">To be added.</param><param name="value">To be added.</param><summary>To be added.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlParameterCollection.SetParameter(System.String,System.Data.Common.DbParameter)">
|
||
|
<param name="parameterName">To be added.</param><param name="value">To be added.</param><summary>To be added.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlRowsCopiedEventArgs">
|
||
|
<summary>Represents the set of arguments passed to the <see cref="T:Microsoft.Data.SqlClient.SqlRowsCopiedEventHandler" />.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlRowsCopiedEventArgs.#ctor(System.Int64)">
|
||
|
<param name="rowsCopied">An <see cref="T:System.Int64" /> that indicates the number of rows copied during the current bulk copy operation.</param><summary>Creates a new instance of the <see cref="T:Microsoft.Data.SqlClient.SqlRowsCopiedEventArgs" /> object.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The value in the `rowsCopied` parameter is reset on each call to any one of the `SqlBulkCopy.WriteToServer` methods.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlRowsCopiedEventArgs.Abort">
|
||
|
<summary>Gets or sets a value that indicates whether the bulk copy operation should be aborted.</summary><value>
|
||
|
<see langword="true" /> if the bulk copy operation should be aborted; otherwise <see langword="false" />.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Use the <xref:Microsoft.Data.SqlClient.SqlRowsCopiedEventArgs.Abort%2A> property to cancel a bulk copy operation. Set <xref:Microsoft.Data.SqlClient.SqlRowsCopiedEventArgs.Abort%2A> to `true` to abort the bulk copy operation.
|
||
|
|
||
|
If you call the **Close** method from <xref:Microsoft.Data.SqlClient.SqlBulkCopy.SqlRowsCopied>, an exception is generated, and the <xref:Microsoft.Data.SqlClient.SqlBulkCopy> object state does not change.
|
||
|
|
||
|
If an application specifically creates a <xref:Microsoft.Data.SqlClient.SqlTransaction> object in the <xref:Microsoft.Data.SqlClient.SqlCommand> constructor, the transaction is not rolled back. The application is responsible for determining whether it is required to rollback the operation, and if so, it must call the <xref:Microsoft.Data.SqlClient.SqlTransaction.Rollback%2A?displayProperty=nameWithType> method. If the application does not create a transaction, the internal transaction corresponding to the current batch is automatically rolled back. However, changes related to previous batches within the bulk copy operation are retained, because the transactions for them already have been committed.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlRowsCopiedEventArgs.RowsCopied">
|
||
|
<summary>Gets a value that returns the number of rows copied during the current bulk copy operation.</summary><value>
|
||
|
<see langword="int" /> that returns the number of rows copied.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The value in the <xref:Microsoft.Data.SqlClient.SqlRowsCopiedEventArgs.RowsCopied%2A> property is reset on each call to any of the `SqlBulkCopy.WriteToServer` methods.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlRowsCopiedEventHandler">
|
||
|
<param name="sender">The source of the event.</param><param name="e">A <see cref="T:Microsoft.Data.SqlClient.SqlRowsCopiedEventArgs" /> object that contains the event data.</param><summary>Represents the method that handles the <see cref="E:Microsoft.Data.SqlClient.SqlBulkCopy.SqlRowsCopied" /> event of a <see cref="T:Microsoft.Data.SqlClient.SqlBulkCopy" />.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlRowUpdatedEventArgs">
|
||
|
<summary>Provides data for the <see cref="E:Microsoft.Data.SqlClient.SqlDataAdapter.RowUpdated" /> event.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlDataAdapter.RowUpdated> event is raised when an <xref:System.Data.Common.DbDataAdapter.Update%2A> to a row is completed.
|
||
|
|
||
|
When using <xref:System.Data.Common.DbDataAdapter.Update%2A>, there are two events that occur for each data row updated. The order of execution is as follows:
|
||
|
|
||
|
1. The values in the <xref:System.Data.DataRow> are moved to the parameter values.
|
||
|
|
||
|
2. The <xref:System.Data.Common.DbDataAdapter.OnRowUpdating%2A> event is raised.
|
||
|
|
||
|
3. The command executes.
|
||
|
|
||
|
4. If the command is set to `FirstReturnedRecord`, and the first returned result is placed in the <xref:System.Data.DataRow>.
|
||
|
|
||
|
5. If there are output parameters, they are placed in the <xref:System.Data.DataRow>.
|
||
|
|
||
|
6. The <xref:System.Data.Common.DbDataAdapter.OnRowUpdated%2A> event is raised.
|
||
|
|
||
|
7. <xref:System.Data.DataRow.AcceptChanges%2A> is called.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example shows how to use both the <xref:Microsoft.Data.SqlClient.SqlDataAdapter.RowUpdating> and <xref:Microsoft.Data.SqlClient.SqlDataAdapter.RowUpdated> events.
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlDataAdapter.RowUpdating> event returns this output:
|
||
|
|
||
|
Event Arguments: (command=Microsoft.Data.SqlClient.SqlCommand commandType=2 status=0)
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlDataAdapter.RowUpdated> event returns this output:
|
||
|
|
||
|
Event Arguments: (command=Microsoft.Data.SqlClient.SqlCommand commandType=2 recordsAffected=1 row=System.Data.DataRow[37] status=0)
|
||
|
|
||
|
[!code-csharp[SqlDataAdapter_RowUpdated Example#1](~/../sqlclient/doc/samples/SqlDataAdapter_RowUpdated.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlRowUpdatedEventArgs.#ctor(System.Data.DataRow,System.Data.IDbCommand,System.Data.StatementType,System.Data.Common.DataTableMapping)">
|
||
|
<param name="row">The <see cref="T:System.Data.DataRow" /> sent through an <see cref="M:System.Data.Common.DbDataAdapter.Update(System.Data.DataSet)" />.</param><param name="command">The <see cref="T:System.Data.IDbCommand" /> executed when <see cref="M:System.Data.Common.DbDataAdapter.Update(System.Data.DataSet)" /> is called.</param><param name="statementType">One of the <see cref="T:System.Data.StatementType" /> values that specifies the type of query executed.</param><param name="tableMapping">The <see cref="T:System.Data.Common.DataTableMapping" /> sent through an <see cref="M:System.Data.Common.DbDataAdapter.Update(System.Data.DataSet)" />.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.SqlRowUpdatedEventArgs" /> class.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlRowUpdatedEventArgs.Command">
|
||
|
<summary>Gets or sets the <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> executed when <see cref="M:System.Data.Common.DbDataAdapter.Update(System.Data.DataSet)" /> is called.</summary><value>The <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> executed when <see cref="M:System.Data.Common.DbDataAdapter.Update(System.Data.DataSet)" /> is called.</value><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlRowUpdatedEventHandler">
|
||
|
<param name="sender">The source of the event.</param><param name="e">The <see cref="T:Microsoft.Data.SqlClient.SqlRowUpdatedEventArgs" /> that contains the event data.</param><summary>Represents the method that will handle the <see cref="E:Microsoft.Data.SqlClient.SqlDataAdapter.RowUpdated" /> event of a <see cref="T:Microsoft.Data.SqlClient.SqlDataAdapter" />.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The handler is not required to perform any action, and your code should avoid generating exceptions or allowing exceptions to propagate to the calling method. Any exceptions that do reach the caller are ignored.
|
||
|
|
||
|
When you create a <xref:Microsoft.Data.SqlClient.SqlRowUpdatedEventArgs> delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](/dotnet/standard/events/).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlRowUpdatingEventArgs">
|
||
|
<summary>Provides data for the <see cref="E:Microsoft.Data.SqlClient.SqlDataAdapter.RowUpdating" /> event.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlDataAdapter.RowUpdating> event is raised before an <xref:System.Data.Common.DbDataAdapter.Update%2A> to a row.
|
||
|
|
||
|
When you are using <xref:System.Data.Common.DbDataAdapter.Update%2A>, there are two events that occur for each data row updated. The order of execution is as follows:
|
||
|
|
||
|
1. The values in the <xref:System.Data.DataRow> are moved to the parameter values.
|
||
|
|
||
|
2. The <xref:System.Data.Common.DbDataAdapter.OnRowUpdating%2A> event is raised.
|
||
|
|
||
|
3. The command executes.
|
||
|
|
||
|
4. If the command is set to `FirstReturnedRecord`, and the first returned result is placed in the <xref:System.Data.DataRow>.
|
||
|
|
||
|
5. If there are output parameters, they are placed in the <xref:System.Data.DataRow>.
|
||
|
|
||
|
6. The <xref:System.Data.Common.DbDataAdapter.OnRowUpdated%2A> event is raised.
|
||
|
|
||
|
7. <xref:System.Data.DataRow.AcceptChanges%2A> is called.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example shows how to use both the <xref:Microsoft.Data.SqlClient.SqlDataAdapter.RowUpdating> and <xref:Microsoft.Data.SqlClient.SqlDataAdapter.RowUpdated> events.
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlDataAdapter.RowUpdating> event returns this output:
|
||
|
|
||
|
event args: (command=Microsoft.Data.SqlClient.SQLCommand commandType=2 status=0)
|
||
|
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlDataAdapter.RowUpdated> event returns this output:
|
||
|
|
||
|
event args: (command=Microsoft.Data.SqlClient.SQLCommand commandType=2 recordsAffected=1 row=System.Data.DataRow[37] status=0)
|
||
|
|
||
|
[!code-csharp[SqlRowUpdatingEventArgs Example#1](~/../sqlclient/doc/samples/SqlRowUpdatingEventArgs.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlRowUpdatingEventArgs.#ctor(System.Data.DataRow,System.Data.IDbCommand,System.Data.StatementType,System.Data.Common.DataTableMapping)">
|
||
|
<param name="row">The <see cref="T:System.Data.DataRow" /> to <see cref="M:System.Data.Common.DbDataAdapter.Update(System.Data.DataSet)" />.</param><param name="command">The <see cref="T:System.Data.IDbCommand" /> to execute during <see cref="M:System.Data.Common.DbDataAdapter.Update(System.Data.DataSet)" />.</param><param name="statementType">One of the <see cref="T:System.Data.StatementType" /> values that specifies the type of query executed.</param><param name="tableMapping">The <see cref="T:System.Data.Common.DataTableMapping" /> sent through an <see cref="M:System.Data.Common.DbDataAdapter.Update(System.Data.DataSet)" />.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.SqlRowUpdatingEventArgs" /> class.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlRowUpdatingEventArgs.BaseCommand">
|
||
|
<summary>To be added.</summary><value>To be added.</value><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlRowUpdatingEventArgs.Command">
|
||
|
<summary>Gets or sets the <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> to execute when performing the <see cref="M:System.Data.Common.DbDataAdapter.Update(System.Data.DataSet)" />.</summary><value>The <see cref="T:Microsoft.Data.SqlClient.SqlCommand" /> to execute when performing the <see cref="M:System.Data.Common.DbDataAdapter.Update(System.Data.DataSet)" />.</value><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlRowUpdatingEventHandler">
|
||
|
<param name="sender">The source of the event.</param><param name="e">The <see cref="T:Microsoft.Data.SqlClient.SqlRowUpdatingEventArgs" /> that contains the event data.</param><summary>Represents the method that will handle the <see cref="E:Microsoft.Data.SqlClient.SqlDataAdapter.RowUpdating" /> event of a <see cref="T:Microsoft.Data.SqlClient.SqlDataAdapter" />.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The handler is not required to perform any action, and your code should avoid generating exceptions or allowing exceptions to propagate to the calling method. Any exceptions that do reach the caller are ignored.
|
||
|
|
||
|
The handler may use the <xref:Microsoft.Data.SqlClient.SqlRowUpdatingEventArgs> to influence the processing of the updates. For example, the handler may opt to skip the update of the current row or skip the update of all remaining rows. Note that the rows are updated in the order that they were received from the data source.
|
||
|
|
||
|
When you create a <xref:Microsoft.Data.SqlClient.SqlRowUpdatingEventArgs> delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see [Handling and Raising Events](/dotnet/standard/events/).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlTransaction">
|
||
|
<summary>Represents a Transact-SQL transaction to be made in a SQL Server database. This class cannot be inherited.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The application creates a <xref:Microsoft.Data.SqlClient.SqlTransaction> object by calling <xref:Microsoft.Data.SqlClient.SqlConnection.BeginTransaction%2A> on the <xref:Microsoft.Data.SqlClient.SqlConnection> object. All subsequent operations associated with the transaction (for example, committing or aborting the transaction), are performed on the <xref:Microsoft.Data.SqlClient.SqlTransaction> object.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> `Try`/`Catch` exception handling should always be used when committing or rolling back a <xref:Microsoft.Data.SqlClient.SqlTransaction>. Both <xref:Microsoft.Data.SqlClient.SqlTransaction.Commit%2A> and <xref:Microsoft.Data.SqlClient.SqlTransaction.Rollback%2A> generate an <xref:System.InvalidOperationException> if the connection is terminated or if the transaction has already been rolled back on the server.
|
||
|
|
||
|
For more information on SQL Server transactions, see [Explicit Transactions](https://msdn.microsoft.com/library/ms175127\(SQL.105\).aspx) and [Coding Efficient Transactions](https://msdn.microsoft.com/library/ms187484\(SQL.105\).aspx).
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlConnection> and a <xref:Microsoft.Data.SqlClient.SqlTransaction>. It also demonstrates how to use the <xref:Microsoft.Data.SqlClient.SqlConnection.BeginTransaction%2A>, <xref:Microsoft.Data.SqlClient.SqlTransaction.Commit%2A>, and <xref:Microsoft.Data.SqlClient.SqlTransaction.Rollback%2A> methods. The transaction is rolled back on any error, or if it is disposed without first being committed. `Try`/`Catch` error handling is used to handle any errors when attempting to commit or roll back the transaction.
|
||
|
|
||
|
[!code-csharp[SqlConnection_BeginTransaction Example#1](~/../sqlclient/doc/samples/SqlConnection_BeginTransaction.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlTransaction.Connection">
|
||
|
<summary>Gets the <see cref="T:Microsoft.Data.SqlClient.SqlConnection" /> object associated with the transaction, or <see langword="null" /> if the transaction is no longer valid.</summary><value>The <see cref="T:Microsoft.Data.SqlClient.SqlConnection" /> object associated with the transaction.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
A single application may have multiple database connections, each with zero or more transactions. This property lets you determine the connection object associated with a particular transaction created by <xref:Microsoft.Data.SqlClient.SqlConnection.BeginTransaction%2A>.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlTransaction.DbConnection">
|
||
|
<summary>To be added.</summary><value>To be added.</value><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlTransaction.IsolationLevel">
|
||
|
<summary>Specifies the <see cref="T:System.Data.IsolationLevel" /> for this transaction.</summary><value>The <see cref="T:System.Data.IsolationLevel" /> for this transaction. The default is <see langword="ReadCommitted" />.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Parallel transactions are not supported. Therefore, the <xref:System.Data.IsolationLevel> applies to the whole transaction.
|
||
|
|
||
|
For more information on SQL Server isolation levels, see [Transaction Isolation Levels](/sql/t-sql/language-elements/transaction-isolation-levels).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlTransaction.Commit">
|
||
|
<summary>Commits the database transaction.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlTransaction.Commit%2A> method is equivalent to the Transact-SQL COMMIT TRANSACTION statement. You cannot roll back a transaction once it has been committed, because all modifications have become a permanent part of the database. For more information, see [COMMIT TRANSACTION (Transact-SQL)](/sql/t-sql/language-elements/commit-transaction-transact-sql).
|
||
|
|
||
|
> [!NOTE]
|
||
|
> `Try`/`Catch` exception handling should always be used when committing or rolling back a <xref:Microsoft.Data.SqlClient.SqlTransaction>. Both `Commit` and <xref:Microsoft.Data.SqlClient.SqlTransaction.Rollback%2A> generates an <xref:System.InvalidOperationException> if the connection is terminated or if the transaction has already been rolled back on the server.
|
||
|
|
||
|
For more information on SQL Server transactions, see [Transactions (Transact-SQL)](/sql/t-sql/language-elements/transactions-transact-sql).
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlConnection> and a <xref:Microsoft.Data.SqlClient.SqlTransaction>. It also demonstrates how to use the <xref:Microsoft.Data.SqlClient.SqlTransaction.Commit%2A>, <xref:Microsoft.Data.SqlClient.SqlConnection.BeginTransaction%2A>, and <xref:Microsoft.Data.SqlClient.SqlTransaction.Rollback%2A> methods. The transaction is rolled back on any error. `Try`/`Catch` error handling is used to handle any errors when attempting to commit or roll back the transaction.
|
||
|
|
||
|
[!code-csharp[SqlConnection_BeginTransaction Example#1](~/../sqlclient/doc/samples/SqlConnection_BeginTransaction.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.Exception">An error occurred while trying to commit the transaction.</exception><exception cref="T:System.InvalidOperationException">The transaction has already been committed or rolled back.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
The connection is broken.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlTransaction.Dispose(System.Boolean)">
|
||
|
<param name="disposing"><see langword="true" /> to release managed and unmanaged resources; <see langword="false" /> to release only unmanaged resources.</param><summary>Releases the unmanaged resources used and optionally releases the managed resources.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This method calls <xref:System.Data.Common.DbTransaction.Dispose%2A>.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlTransaction.Rollback">
|
||
|
<summary>Rolls back a transaction from a pending state.</summary>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlTransaction.Rollback(System.String)">
|
||
|
<summary>Rolls back a transaction from a pending state.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The <xref:Microsoft.Data.SqlClient.SqlTransaction.Rollback%2A> method is equivalent to the Transact-SQL ROLLBACK TRANSACTION statement. For more information, see [ROLLBACK TRANSACTION (Transact-SQL)
|
||
|
](/sql/t-sql/language-elements/rollback-transaction-transact-sql).
|
||
|
|
||
|
The transaction can only be rolled back from a pending state (after <xref:Microsoft.Data.SqlClient.SqlConnection.BeginTransaction%2A> has been called, but before <xref:Microsoft.Data.SqlClient.SqlTransaction.Commit%2A> is called). The transaction is rolled back in the event it is disposed before `Commit` or `Rollback` is called.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> `Try`/`Catch` exception handling should always be used when rolling back a transaction. A `Rollback` generates an <xref:System.InvalidOperationException> if the connection is terminated or if the transaction has already been rolled back on the server.
|
||
|
|
||
|
For more information on SQL Server transactions, see [Transactions (Transact-SQL)](/sql/t-sql/language-elements/transactions-transact-sql).
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlConnection> and a <xref:Microsoft.Data.SqlClient.SqlTransaction>. It also demonstrates how to use the <xref:Microsoft.Data.SqlClient.SqlConnection.BeginTransaction%2A>, <xref:Microsoft.Data.SqlClient.SqlTransaction.Commit%2A>, and <xref:Microsoft.Data.SqlClient.SqlTransaction.Rollback%2A> methods. The transaction is rolled back on any error. `Try`/`Catch` error handling is used to handle any errors when attempting to commit or roll back the transaction.
|
||
|
|
||
|
[!code-csharp[SqlConnection_BeginTransaction Example#1](~/../sqlclient/doc/samples/SqlConnection_BeginTransaction.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.Exception">An error occurred while trying to commit the transaction.</exception><exception cref="T:System.InvalidOperationException">The transaction has already been committed or rolled back.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
The connection is broken.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlTransaction.Save(System.String)">
|
||
|
<param name="savePointName">The name of the savepoint.</param><summary>Creates a savepoint in the transaction that can be used to roll back a part of the transaction, and specifies the savepoint name.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
<xref:Microsoft.Data.SqlClient.SqlTransaction.Save%2A> method is equivalent to the Transact-SQL SAVE TRANSACTION statement.
|
||
|
|
||
|
The value used in the `savePoint` parameter can be the same value used in the `transactionName` parameter of some implementations of the <xref:Microsoft.Data.SqlClient.SqlConnection.BeginTransaction%2A> method.
|
||
|
|
||
|
Savepoints offer a mechanism to roll back parts of transactions. You create a savepoint using the <xref:Microsoft.Data.SqlClient.SqlTransaction.Save%2A> method, and then later call the <xref:Microsoft.Data.SqlClient.SqlTransaction.Rollback%2A> method to roll back to the savepoint instead of rolling back to the start of the transaction.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.Exception">An error occurred while trying to commit the transaction.</exception><exception cref="T:System.InvalidOperationException">The transaction has already been committed or rolled back.
|
||
|
|
||
|
-or-
|
||
|
|
||
|
The connection is broken.</exception>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlRetryingEventArgs">
|
||
|
<summary>Represents the set of arguments passed to the <see cref="E:Microsoft.Data.SqlClient.SqlRetryLogicBaseProvider.Retrying" /> event.</summary>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlRetryingEventArgs.#ctor(System.Int32,System.TimeSpan,System.Collections.Generic.IList{System.Exception})">
|
||
|
<param name="retryCount">The current retry attempt count.</param><param name="delay">The delay that indicates how long the current thread will be suspended before the next iteration is invoked.</param><param name="exceptions">The list of exceptions since the first retry that caused the retry logic to re-execute the function.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.SqlRetryingEventArgs" /> class.</summary>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlRetryingEventArgs.RetryCount">
|
||
|
<summary>Retry-attempt-number, after the first exception occurrence.</summary><value>
|
||
|
<see langword="int" /> that returns the number of retry execution attempts; starting from 1.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlRetryingEventArgs.Delay">
|
||
|
<summary>Gets the current waiting time as a <see cref="T:System.TimeSpan" /> object.</summary><value>
|
||
|
<see cref="T:System.TimeSpan" /> The upcoming gap time before the next execution attempt.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlRetryingEventArgs.Cancel">
|
||
|
<summary>Gets or sets a value that indicates whether the retry logic should be canceled.</summary><value> If set to <see langword="true" />, the execution attempt will be interrupted immediately.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlRetryingEventArgs.Exceptions">
|
||
|
<summary>Gets the list of exceptions since the first attempt failure.</summary><value>List of occurred exceptions.</value>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlRetryIntervalBaseEnumerator">
|
||
|
<summary>Generates a sequence of time intervals.</summary>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlRetryIntervalBaseEnumerator.GapTimeInterval">
|
||
|
<summary>The default gap time of each interval.</summary>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlRetryIntervalBaseEnumerator.MaxTimeInterval">
|
||
|
<summary>The maximum allowed time interval value.</summary>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlRetryIntervalBaseEnumerator.MinTimeInterval">
|
||
|
<summary>The minimum allowed time interval value.</summary>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlRetryIntervalBaseEnumerator.Current">
|
||
|
<summary>Gets the element in the collection at the current position of the enumerator.</summary>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlRetryIntervalBaseEnumerator.#ctor">
|
||
|
<summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.SqlRetryIntervalBaseEnumerator" /> class with a default value of zero for the gap time, minimum, and maximum interval time.</summary>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlRetryIntervalBaseEnumerator.#ctor(System.TimeSpan,System.TimeSpan,System.TimeSpan)">
|
||
|
<param name="timeInterval">The gap time used to calculate the time delay before each attempt.</param><param name="maxTime">The maximum time allowed as a gap time.</param><param name="minTime">The minimum time allowed as a gap time.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.SqlRetryIntervalBaseEnumerator" /> class.</summary><exception cref="T:System.ArgumentOutOfRangeException">The supplied arguments failed <see cref="M:Microsoft.Data.SqlClient.SqlRetryIntervalBaseEnumerator.Validate(System.TimeSpan,System.TimeSpan,System.TimeSpan)" /> validation.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlRetryIntervalBaseEnumerator.Reset">
|
||
|
<summary>Sets the enumerator to its initial position, which is before the first element in the collection.</summary>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlRetryIntervalBaseEnumerator.Validate(System.TimeSpan,System.TimeSpan,System.TimeSpan)">
|
||
|
<param name="timeInterval">The gap time of each interval. Must be between 0 and 120 seconds.</param><param name="maxTimeInterval">Maximum time interval value. Must be between 0 and 120 seconds.</param><param name="minTimeInterval">Minimum time interval value. Must be less than maximum time interval and between 0 and 120 seconds.</param><summary>Validate the enumeration parameters.</summary><exception cref="T:System.ArgumentOutOfRangeException">The supplied arguments failed validation.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlRetryIntervalBaseEnumerator.GetNextInterval">
|
||
|
<summary>Calculates the next interval time.</summary><returns>Returns the next gap time interval.</returns>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlRetryIntervalBaseEnumerator.MoveNext">
|
||
|
<summary>Advances the enumerator to the next element of the collection.</summary><returns>Returns <see langword="true" />, if the enumerator was successfully advanced to the next element; <see langword="false" /> if the enumerator has passed the end of the collection.</returns>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlRetryIntervalBaseEnumerator.Dispose">
|
||
|
<summary>Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.</summary>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlRetryIntervalBaseEnumerator.Clone">
|
||
|
<summary>Creates a new object that is a copy of the current instance.</summary><returns>A new object that is a copy of this instance.</returns>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlRetryLogicBase">
|
||
|
<summary>Retrieves the next time interval with respect to the number of retries if a transient condition occurs.</summary>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlRetryLogicBase.NumberOfTries">
|
||
|
<summary>Maximum number of retries.</summary><value>
|
||
|
<see langword="int" /> that returns the maximum number of retry execution attempts that will be attempted after the first failure.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlRetryLogicBase.Current">
|
||
|
<summary>Current retry number starting from zero.</summary><value>
|
||
|
<see langword="int" /> that returns the number of retry execution attempts after the first failure.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlRetryLogicBase.RetryIntervalEnumerator">
|
||
|
<summary>The timer interval enumerator.</summary><value>
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlRetryIntervalBaseEnumerator" /> value that indicates an enumerator to generate a sequence of time intervals.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlRetryLogicBase.TransientPredicate">
|
||
|
<summary>Delegate to a transient condition predicate. The function that this delegate points to must return a true value when an expected transient exception happens.</summary><value>
|
||
|
<see cref="T:System.Predicate`1" /> value that delegates to a function that receives a <see cref="T:System.Exception" /> input parameter.</value>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlRetryLogicBase.RetryCondition(System.Object)">
|
||
|
<param name="sender">The sender object.</param><summary>Pre-retry validation for the sender state.</summary><returns>Returns <see langword="true" /> if the sender is authorized to retry the operation.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
> [IMPORTANT!]
|
||
|
> Operations that are part of a **Transaction** are not safe to retry without specific knowledge of business logic. Due to this complexity, retry logic should be managed at the application level.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> The `RetryCondition` is an extra condition that checks before executing the `TransientPredicate` and the default condition always returns **true**.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlRetryLogicBase.TryNextInterval(System.TimeSpan@)">
|
||
|
<param name="intervalTime">The interval time that is generated by the `RetryIntervalEnumerator`.</param><summary>Try to get the next interval time by using the enumerator if the counter does not exceed the number of retries.</summary><returns>Returns <see langword="true" /> if the number of retry attempts has not been exceeded; otherwise <see langword="false" />.</returns>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlRetryLogicBase.Reset">
|
||
|
<summary>Set the counters and enumerator to default values for next use.</summary>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlRetryLogicBase.Clone">
|
||
|
<summary>Creates a new object that is a copy of the current instance.</summary><returns>When implemented in a derived class, the method is expected to return a new object of the current instance. The default implementation throws NotImplementedException.</returns><exception cref="T:System.NotImplementedException">In all cases.</exception>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlRetryLogicBaseProvider">
|
||
|
<summary>Applies retry logic on an operation through the `Execute` or `ExecuteAsync` function.</summary>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlRetryLogicBaseProvider.Retrying">
|
||
|
<summary>Occurs before applying the calculated delay time and executing the function on a next attempt.</summary><value>
|
||
|
<see cref="T:System.EventHandler" /> with event argument of <see cref="T:Microsoft.Data.SqlClient.SqlRetryingEventArgs" /> object can be subscribed.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
> [IMPORTANT!]
|
||
|
> Don't block execution with a time consuming action when an event occurs. For instance, if you log data to a file, run it in a new thread to avoid blocking the main execution thread.
|
||
|
|
||
|
]]>
|
||
|
</format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlRetryLogicBaseProvider.RetryLogic">
|
||
|
<summary>Defines the retry logic used to decide when to retry based on the encountered exception.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
> [!NOTE]
|
||
|
> The `RetryLogic` property is assigned at `SqlRetryLogicBaseProvider` creation and its value is used as a template internally. Don't use it to monitor the status of the retry logic during and after execution. Instead, use the <xref=E:Microsoft.Data.SqlClient.SqlRetryLogicBaseProvider.Retrying> event to collect data about retry executions.
|
||
|
|
||
|
]]>
|
||
|
</format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlRetryLogicBaseProvider.Execute``1(System.Object,System.Func{``0})">
|
||
|
<typeparam name="TResult">The object that the `function` returns when executed.</typeparam><param name="sender">The source of the event.</param><param name="function">The operation to re-execute if a transient condition occurs.</param><summary>Executes a function and applies retry logic, if enabled. **Note:** Exceptions will be reported via an aggregate exception if the execution isn't successful via retry attempts.
|
||
|
</summary><returns>The return value of the `function` if it runs without exception.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
> [!NOTE]
|
||
|
> The type of exception depends on the `function`'s internal implementation. But if the exception is due to all retry attempts failing, it will be an <xref:System.AggregateException> that consists of all exceptions that happened during the failed attempts.
|
||
|
|
||
|
]]>
|
||
|
</format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">The `function` parameter can't be `null`.</exception><exception cref="T:System.AggregateException">The collection of exceptions after all retry attempts have failed.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlRetryLogicBaseProvider.ExecuteAsync``1(System.Object,System.Func{System.Threading.Tasks.Task{``0}},System.Threading.CancellationToken)">
|
||
|
<typeparam name="TResult">The object that the `function` returns in a Task when executed.</typeparam><param name="sender">The source of the event.</param><param name="function">The operation to re-execute if a transient condition occurs.</param><param name="cancellationToken">The cancellation instruction.</param><summary>Executes a function and applies retry logic, if enabled. The cancellation token can be used to request that the operation be abandoned before the execution attempts are exceeded. **Note:** Exceptions will be reported via the returned Task object, which will contain an aggregate exception if execution fails for all retry attempts.</summary><returns>A task representing the asynchronous operation. The results of the task will be the return value of the `function`, if it runs without exception.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
> [!NOTE]
|
||
|
> If the exception comes from all retry attempts failing, it will be an <xref:System.AggregateException> that consists of all exceptions from the failed attempts.
|
||
|
|
||
|
]]>
|
||
|
</format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">The `function` parameter can't be `null`.</exception><exception cref="T:System.AggregateException">The collection of exceptions after failed retry attempts.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlRetryLogicBaseProvider.ExecuteAsync(System.Object,System.Func{System.Threading.Tasks.Task},System.Threading.CancellationToken)">
|
||
|
<param name="sender">The source of the event.</param><param name="function">The operation to re-execute if a transient condition occurs.</param><param name="cancellationToken">The cancellation instruction.</param><summary>Executes a function and applies retry logic, if enabled. The cancellation token can be used to request that the operation be abandoned before the execution attempts are exceeded. **Note:** Exceptions will be reported via the returned Task object, which will contain an aggregate exception if execution fails for all retry attempts.</summary><returns>A Task or an exception.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
> [!NOTE]
|
||
|
> If the exception comes from all retry attempts failing, it will be an <xref:System.AggregateException> that consists of all exceptions from the failed attempts.
|
||
|
|
||
|
]]>
|
||
|
</format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">The `function` parameter can't be `null`.</exception><exception cref="T:System.AggregateException">The collection of exceptions after failed retry attempts.</exception>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlRetryLogicOption">
|
||
|
<summary>Provides the retry logic parameters to create an instance of the <see cref="T:Microsoft.Data.SqlClient.SqlRetryLogicBaseProvider" /> class by using <see cref="T:Microsoft.Data.SqlClient.SqlConfigurableRetryFactory" /> methods.</summary>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlRetryLogicOption.NumberOfTries">
|
||
|
<summary>Sets the number of times to try and execute the function.</summary><value>
|
||
|
<see langword="int" /> between 1 and 60; 1 means to execute one time and if an error is encountered, don't retry.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlRetryLogicOption.DeltaTime">
|
||
|
<summary>Sets the gap time interval as a <see cref="T:System.TimeSpan" /> object.</summary><value>
|
||
|
<see cref="T:System.TimeSpan" /> The upcoming gap time before the next execution attempt; must be between 0 and 120 seconds.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlRetryLogicOption.MinTimeInterval">
|
||
|
<summary>Sets the minimum allowed gap time interval as a <see cref="T:System.TimeSpan" /> object.</summary><value>
|
||
|
<see cref="T:System.TimeSpan" /> The minimum upcoming gap time before the next execution attempt; the default value is **zero** and must be between 0 and 120 seconds.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlRetryLogicOption.MaxTimeInterval">
|
||
|
<summary>Sets the allowed maximum gap time interval as a <see cref="T:System.TimeSpan" /> object.</summary><value>
|
||
|
<see cref="T:System.TimeSpan" /> The maximum upcoming gap time interval before the next execution attempt; must be between 0 and 120 seconds.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlRetryLogicOption.TransientErrors">
|
||
|
<summary>Sets the list of transient error numbers on which to retry when they occur.</summary><value>List of <see cref="T:Microsoft.Data.SqlClient.SqlException.Number" />; Set to <see langword="null" /> to use the internal list of exceptions from the <see cref="T:Microsoft.Data.SqlClient.SqlConfigurableRetryFactory" /> object.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlRetryLogicOption.AuthorizedSqlCondition">
|
||
|
<summary>Sets a pre-retry validation function on the <see cref="T:Microsoft.Data.SqlClient.SqlCommand.CommandText" /> to only include specific SQL statements.</summary><value>
|
||
|
<see cref="T:System.Predicate`1" /> The pre-retry validation delegate function; <see langword="true" /> if the `CommandText` is authorized to retry the operation.</value>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlConfigurableRetryFactory">
|
||
|
<summary>Provides different retry logic providers with a common list of transient errors.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The following table shows the inner transient error list.
|
||
|
|
||
|
|Error Number|Description|
|
||
|
|-------------|-----------------|
|
||
|
|1204|The instance of the SQL Server Database Engine cannot obtain a LOCK resource at this time. Rerun your statement when there are fewer active users. Ask the database administrator to check the lock and memory configuration for this instance, or to check for long-running transactions.|
|
||
|
|1205|Transaction (Process ID) was deadlocked on resources with another process and has been chosen as the deadlock victim. Rerun the transaction.|
|
||
|
|1222|Lock request time out period exceeded.|
|
||
|
|49918|Cannot process request. Not enough resources to process request.|
|
||
|
|49919|Cannot process create or update request. Too many create or update operations in progress for subscription "%ld".|
|
||
|
|49920|Cannot process request. Too many operations in progress for subscription "%ld".|
|
||
|
|4060|Cannot open database "%.*ls" requested by the login. The login failed.|
|
||
|
|4221|Login to read-secondary failed due to long wait on 'HADR_DATABASE_WAIT_FOR_TRANSITION_TO_VERSIONING'. The replica is not available for login because row versions are missing for transactions that were in-flight when the replica was recycled. The issue can be resolved by rolling back or committing the active transactions on the primary replica. Occurrences of this condition can be minimized by avoiding long write transactions on the primary.|
|
||
|
|40143|The service has encountered an error processing your request. Please try again.|
|
||
|
|40613|Database '%.*ls' on server '%.*ls' is not currently available. Please retry the connection later. If the problem persists, contact customer support, and provide them the session tracing ID of '%.*ls'.|
|
||
|
|40501|The service is currently busy. Retry the request after 10 seconds. Incident ID: %ls. Code: %d.|
|
||
|
|40540|The service has encountered an error processing your request. Please try again.|
|
||
|
|40197|The service has encountered an error processing your request. Please try again. Error code %d.|
|
||
|
|10929|Resource ID: %d. The %s minimum guarantee is %d, maximum limit is %d and the current usage for the database is %d. However, the server is currently too busy to support requests greater than %d for this database. For more information, see http://go.microsoft.com/fwlink/?LinkId=267637. Otherwise, please try again later.|
|
||
|
|10928|Resource ID: %d. The %s limit for the database is %d and has been reached. For more information, see http://go.microsoft.com/fwlink/?LinkId=267637.|
|
||
|
|10060|An error has occurred while establishing a connection to the server. When connecting to SQL Server, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.) (Microsoft SQL Server, Error: 10060)|
|
||
|
|10054|The data value for one or more columns overflowed the type used by the provider.|
|
||
|
|10053|Could not convert the data value due to reasons other than sign mismatch or overflow.|
|
||
|
|997|A connection was successfully established with the server, but then an error occurred during the login process. (provider: Named Pipes Provider, error: 0 - Overlapped I/O operation is in progress)|
|
||
|
|233|A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.) (Microsoft SQL Server, Error: 233)|
|
||
|
|
||
|
]]>
|
||
|
</format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConfigurableRetryFactory.CreateExponentialRetryProvider(Microsoft.Data.SqlClient.SqlRetryLogicOption)">
|
||
|
<param name="retryLogicOption">An object of <see cref="T:Microsoft.Data.SqlClient.SqlRetryLogicOption" /> containing the configuration for the object.</param><summary>Provides an exponential time interval retry logic provider.</summary><returns>A <see cref="T:Microsoft.Data.SqlClient.SqlRetryLogicBaseProvider" /> object.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
> [!NOTE]
|
||
|
> The inner enumerator includes randomization to prevent multiple instances of the client from performing subsequent retry attempts at the same time.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">If the `retryLogicOption` parameter was null.</exception><exception cref="T:System.ArgumentOutOfRangeException">If at least one of the following conditions occurs:
|
||
|
- `NumberOfTries` is less than 1 or bigger than 60.
|
||
|
- `DeltaTime` is bigger than 120 seconds.
|
||
|
- `MinTimeInterval` is bigger than 120 seconds.
|
||
|
- `MaxTimeInterval` is bigger than 120 seconds.
|
||
|
- `MinTimeInterval` is not less than `MaxTimeInterval`.
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConfigurableRetryFactory.CreateIncrementalRetryProvider(Microsoft.Data.SqlClient.SqlRetryLogicOption)">
|
||
|
<param name="retryLogicOption">An object of <see cref="T:Microsoft.Data.SqlClient.SqlRetryLogicOption" /> containing the configuration for the object.</param><summary>Provides an incremental time interval retry logic provider.</summary><returns>A <see cref="T:Microsoft.Data.SqlClient.SqlRetryLogicBaseProvider" /> object.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
> [!NOTE]
|
||
|
> The inner enumerator includes randomization to prevent multiple instances of the client from performing subsequent retry attempts at the same time.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">If the `retryLogicOption` parameter was null.</exception><exception cref="T:System.ArgumentOutOfRangeException">If at least one of the following conditions occurs:
|
||
|
- `NumberOfTries` is less than 1 or bigger than 60.
|
||
|
- `DeltaTime` is bigger than 120 seconds.
|
||
|
- `MinTimeInterval` is bigger than 120 seconds.
|
||
|
- `MaxTimeInterval` is bigger than 120 seconds.
|
||
|
- `MinTimeInterval` is not less than `MaxTimeInterval`.
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConfigurableRetryFactory.CreateFixedRetryProvider(Microsoft.Data.SqlClient.SqlRetryLogicOption)">
|
||
|
<param name="retryLogicOption">An object of <see cref="T:Microsoft.Data.SqlClient.SqlRetryLogicOption" /> containing the configuration for the object.</param><summary>Provides a fixed interval time retry logic provider.</summary><returns>A <see cref="T:Microsoft.Data.SqlClient.SqlRetryLogicBaseProvider" /> object.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
> [!NOTE]
|
||
|
> The inner enumerator includes randomization to prevent multiple instances of the client from performing subsequent retry attempts at the same time.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">If the `retryLogicOption` parameter was null.</exception><exception cref="T:System.ArgumentOutOfRangeException">If at least one of the following conditions occurs:
|
||
|
- `NumberOfTries` is less than 1 or bigger than 60.
|
||
|
- `DeltaTime` is bigger than 120 seconds.
|
||
|
- `MinTimeInterval` is bigger than 120 seconds.
|
||
|
- `MaxTimeInterval` is bigger than 120 seconds.
|
||
|
- `MinTimeInterval` is not less than `MaxTimeInterval`.
|
||
|
</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlConfigurableRetryFactory.CreateNoneRetryProvider">
|
||
|
<summary>Provides a non-retriable provider with a <see cref="T:Microsoft.Data.SqlClient.SqlRetryLogicBase.TransientPredicate" /> that returns <see langword="false" />.</summary><returns>A <see cref="T:Microsoft.Data.SqlClient.SqlRetryLogicBaseProvider" /> object.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
> [!NOTE]
|
||
|
> The returned provider of this function performs a single execution without any retry logic.
|
||
|
|
||
|
]]>
|
||
|
</format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.Server.SqlDataRecord">
|
||
|
<summary>Represents a single row of data and its metadata.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This class is used together with <xref:Microsoft.SqlServer.Server.SqlPipe> to send result sets to the client from managed code stored-procedures.
|
||
|
|
||
|
When writing common language runtime (CLR) applications, you should re-use existing `SqlDataRecord` objects instead of creating new ones every time. Creating many new `SqlDataRecord` objects could severely deplete memory and adversely affect performance.
|
||
|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example shows how to create several <xref:Microsoft.Data.SqlClient.Server.SqlMetaData> objects, which describe the column metadata of a record, and creating a <xref:Microsoft.Data.SqlClient.Server.SqlDataRecord>. The column values of the <xref:Microsoft.Data.SqlClient.Server.SqlDataRecord> are set and the <xref:Microsoft.Data.SqlClient.Server.SqlDataRecord> is sent to the calling program by using the <xref:Microsoft.SqlServer.Server.SqlContext> class.
|
||
|
|
||
|
[!code-csharp[SqlDataRecord Samples#1](~/../sqlclient/doc/samples/SqlDataRecord.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.#ctor(Microsoft.Data.SqlClient.Server.SqlMetaData[])">
|
||
|
<param name="metaData">An array of <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> objects that describe each column in the <see cref="T:Microsoft.Data.SqlClient.Server.SqlDataRecord" />.</param><summary>Inititializes a new <see cref="T:Microsoft.Data.SqlClient.Server.SqlDataRecord" /> instance with the schema based on the array of <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> objects passed as an argument.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Examples
|
||
|
The following example shows how to create a new <xref:Microsoft.Data.SqlClient.Server.SqlDataRecord> object from two <xref:Microsoft.Data.SqlClient.Server.SqlMetaData> objects, which indicate the column name and data type.
|
||
|
|
||
|
[!code-csharp[SqlDataRecord Samples#2](~/../sqlclient/doc/samples/SqlDataRecord.cs#2)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">The <paramref name="metaData" /> is <see langword="null" />.</exception>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount">
|
||
|
<summary>Gets the number of columns in the data row. This property is read-only.</summary><value>The number of columns in the data row as an integer.</value><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.Item(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Gets the common language runtime (CLR) type value for the column specified by the column <paramref name="ordinal" /> argument.</summary><value>The CLR type value of the column specified by the <paramref name="ordinal" />.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
For columns with null value, <xref:System.DBNull.Value> is returned.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.Item(System.String)">
|
||
|
<param name="name">The name of the column.</param><summary>Gets the common language runtime (CLR) type value for the column specified by the column <paramref name="name" /> argument.</summary><value>The CLR type value of the column specified by the <paramref name="name" />.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
For columns with null value, <xref:System.DBNull.Value> is returned.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetBoolean(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Gets the value for the column specified by the ordinal as a <see cref="T:System.Boolean" />.</summary><returns>The column value as a <see cref="T:System.Boolean" />.</returns><remarks>To be added.</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.Data.SqlTypes.SqlNullValueException">The column specified by <paramref name="ordinal" /> is null.</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetByte(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Gets the value for the column specified by the ordinal as a <see cref="T:System.Byte" />.</summary><returns>The column value as a <see cref="T:System.Byte" />.</returns><remarks>To be added.</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.Data.SqlTypes.SqlNullValueException">The column specified by <paramref name="ordinal" /> is null.</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetBytes(System.Int32,System.Int64,System.Byte[],System.Int32,System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="fieldOffset">The offset into the field value to start retrieving bytes.</param><param name="buffer">The target buffer to which to copy bytes.</param><param name="bufferOffset">The offset into the buffer to which to start copying bytes.</param><param name="length">The number of bytes to copy to the buffer.</param><summary>Gets the value for the column specified by the ordinal as an array of <see cref="T:System.Byte" /> objects.</summary><returns>The number of bytes copied.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This method enables you to obtain a binary value either in a single call or in chunks. Getting the value in chunks is useful for large values or values of unknown size.
|
||
|
|
||
|
To obtain the value in several chunks, allocate a byte array of the chunk-size and call <xref:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetBytes%2A> repeatedly, adjusting the `fieldOffset` parameter accordingly in each call.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.Data.SqlTypes.SqlNullValueException">The column specified by <paramref name="ordinal" /> is null.</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetChar(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Gets the value for the column specified by the ordinal as a <see cref="T:System.Char" />.</summary><returns>The column value as a <see cref="T:System.Char" />.</returns><remarks>To be added.</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.Data.SqlTypes.SqlNullValueException">The column specified by <paramref name="ordinal" /> is null.</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetChars(System.Int32,System.Int64,System.Char[],System.Int32,System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="fieldOffset">The offset into the field value to start retrieving characters.</param><param name="buffer">The target buffer to copy chars to.</param><param name="bufferOffset">The offset into the buffer to start copying chars to.</param><param name="length">The number of chars to copy to the buffer.</param><summary>Gets the value for the column specified by the ordinal as an array of <see cref="T:System.Char" /> objects.</summary><returns>The number of characters copied.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This method enables you to obtain a character value either in a single call or in chunks. Getting the value in chunks is useful for large values or values of unknown size.
|
||
|
|
||
|
To obtain the value in several chunks, allocate a char array of the chunk-size and call <xref:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetChars%2A> repeatedly adjusting the `fieldOffset` parameter accordingly in each call.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.Data.SqlTypes.SqlNullValueException">The column specified by <paramref name="ordinal" /> is null.</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.System#Data#IDataRecord#GetData(System.Int32)">
|
||
|
<param name="ordinal">To be added.</param><summary>To be added.</summary><returns>To be added.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetDataTypeName(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Returns the name of the data type for the column specified by the ordinal argument.</summary><returns>A <see cref="T:System.String" /> that contains the data type of the column.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This method returns the type name as known in the SQL Server type-system. For user-defined types (UDTs), it returns the three-part name that was used to register the type with SQL Server.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetDateTime(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Gets the value for the column specified by the ordinal as a <see cref="T:System.DateTime" />.</summary><returns>The column value as a <see cref="T:System.DateTime" />.</returns><remarks>To be added.</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.Data.SqlTypes.SqlNullValueException">The column specified by <paramref name="ordinal" /> is null.</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetDateTimeOffset(System.Int32)">
|
||
|
<param name="ordinal">The zero-based column ordinal.</param><summary>Returns the specified column's data as a <see cref="T:System.DateTimeOffset" />.</summary><returns>The value of the specified column as a <see cref="T:System.DateTimeOffset" />.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetDecimal(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Gets the value for the column specified by the ordinal as a <see cref="T:System.Decimal" />.</summary><returns>The column value as a <see cref="T:System.Decimal" />.</returns><remarks>To be added.</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.Data.SqlTypes.SqlNullValueException">The column specified by <paramref name="ordinal" /> is null.</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetDouble(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Gets the value for the column specified by the ordinal as a <see cref="T:System.Double" />.</summary><returns>The column value as a <see cref="T:System.Double" />.</returns><remarks>To be added.</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.Data.SqlTypes.SqlNullValueException">The column specified by <paramref name="ordinal" /> is null.</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetFieldType(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Returns a <see cref="T:System.Type" /> object representing the common language runtime (CLR) type that maps to the SQL Server type of the column specified by the <paramref name="ordinal" /> argument.</summary><returns>The column type as a <see cref="T:System.Type" /> object.</returns><remarks>To be added.</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.TypeLoadException">The column is of a user-defined type that is not available to the calling application domain.</exception><exception cref="T:System.IO.FileNotFoundException">The column is of a user-defined type that is not available to the calling application domain.</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetFloat(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Gets the value for the column specified by the ordinal as a <see langword="float" />.</summary><returns>The column value as a <see langword="float" />.</returns><remarks>To be added.</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.Data.SqlTypes.SqlNullValueException">The column specified by <paramref name="ordinal" /> is null.</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetGuid(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Gets the value for the column specified by the ordinal as a <see cref="T:System.Guid" />.</summary><returns>The column value as a <see cref="T:System.Guid" />.</returns><remarks>To be added.</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.Data.SqlTypes.SqlNullValueException">The column specified by <paramref name="ordinal" /> is null.</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetInt16(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Gets the value for the column specified by the ordinal as a <see cref="T:System.Int16" />.</summary><returns>The column value as a <see cref="T:System.Int16" />.</returns><remarks>To be added.</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.Data.SqlTypes.SqlNullValueException">The column specified by <paramref name="ordinal" /> is null.</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetInt32(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Gets the value for the column specified by the ordinal as a <see cref="T:System.Int32" />.</summary><returns>The column value as a <see cref="T:System.Int32" />.</returns><remarks>To be added.</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.Data.SqlTypes.SqlNullValueException">The column specified by <paramref name="ordinal" /> is null.</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetInt64(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Gets the value for the column specified by the ordinal as a <see cref="T:System.Int64" />.</summary><returns>The column value as a <see cref="T:System.Int64" />.</returns><remarks>To be added.</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.Data.SqlTypes.SqlNullValueException">The column specified by <paramref name="ordinal" /> is null.</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetName(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Returns the name of the column specified by the ordinal argument.</summary><returns>A <see cref="T:System.String" /> containing the column name.</returns><remarks>To be added.</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetOrdinal(System.String)">
|
||
|
<param name="name">The name of the column to look up.</param><summary>Returns the column ordinal specified by the column name.</summary><returns>The zero-based ordinal of the column as an integer.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentNullException">
|
||
|
<paramref name="name" /> is <see langword="null" />.</exception><exception cref="T:System.IndexOutOfRangeException">The column name could not be found.</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetSqlBinary(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Gets the value for the column specified by the ordinal as a <see cref="T:System.Data.SqlTypes.SqlBinary" />.</summary><returns>The column value as a <see cref="T:System.Data.SqlTypes.SqlBinary" />.</returns><remarks>To be added.</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetSqlBoolean(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Gets the value for the column specified by the ordinal as a <see cref="T:System.Data.SqlTypes.SqlBoolean" />.</summary><returns>The column value as a <see cref="T:System.Data.SqlTypes.SqlBoolean" />.</returns><remarks>To be added.</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetSqlByte(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Gets the value for the column specified by the ordinal as a <see cref="T:System.Data.SqlTypes.SqlByte" />.</summary><returns>The column value as a <see cref="T:System.Data.SqlTypes.SqlByte" />.</returns><remarks>To be added.</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetSqlBytes(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Gets the value for the column specified by the ordinal as a <see cref="T:System.Data.SqlTypes.SqlBytes" />.</summary><returns>The column value as a <see cref="T:System.Data.SqlTypes.SqlBytes" />.</returns><remarks>To be added.</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetSqlChars(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Gets the value for the column specified by the ordinal as a <see cref="T:System.Data.SqlTypes.SqlChars" />.</summary><returns>The column value as a <see cref="T:System.Data.SqlTypes.SqlChars" />.</returns><remarks>To be added.</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetSqlDateTime(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Gets the value for the column specified by the ordinal as a <see cref="T:System.Data.SqlTypes.SqlDateTime" />.</summary><returns>The column value as a <see cref="T:System.Data.SqlTypes.SqlDateTime" />.</returns><remarks>To be added.</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetSqlDecimal(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Gets the value for the column specified by the ordinal as a <see cref="T:System.Data.SqlTypes.SqlDecimal" />.</summary><returns>The column value as a <see cref="T:System.Data.SqlTypes.SqlDecimal" />.</returns><remarks>To be added.</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetSqlDouble(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Gets the value for the column specified by the ordinal as a <see cref="T:System.Data.SqlTypes.SqlDouble" />.</summary><returns>The column value as a <see cref="T:System.Data.SqlTypes.SqlDouble" />.</returns><remarks>To be added.</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetSqlFieldType(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Returns a <see cref="T:System.Type" /> object that represents the type (as a SQL Server type, defined in <see cref="N:System.Data.SqlTypes" />) that maps to the SQL Server type of the column.</summary><returns>The column type as a <see cref="T:System.Type" /> object.</returns><remarks>To be added.</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.TypeLoadException">The column is of a user-defined type that is not available to the calling application domain.</exception><exception cref="T:System.IO.FileNotFoundException">The column is of a user-defined type that is not available to the calling application domain.</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetSqlGuid(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Gets the value for the column specified by the ordinal as a <see cref="T:System.Data.SqlTypes.SqlGuid" />.</summary><returns>The column value as a <see cref="T:System.Data.SqlTypes.SqlGuid" />.</returns><remarks>To be added.</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetSqlInt16(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Gets the value for the column specified by the ordinal as a <see cref="T:System.Data.SqlTypes.SqlInt16" />.</summary><returns>The column value as a <see cref="T:System.Data.SqlTypes.SqlInt16" />.</returns><remarks>To be added.</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetSqlInt32(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Gets the value for the column specified by the ordinal as a <see cref="T:System.Data.SqlTypes.SqlInt32" />.</summary><returns>The column value as a <see cref="T:System.Data.SqlTypes.SqlInt32" />.</returns><remarks>To be added.</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetSqlInt64(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Gets the value for the column specified by the ordinal as a <see cref="T:System.Data.SqlTypes.SqlInt64" />.</summary><returns>The column value as a <see cref="T:System.Data.SqlTypes.SqlInt64" />.</returns><remarks>To be added.</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetSqlMetaData(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Returns a <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> object, describing the metadata of the column specified by the column ordinal.</summary><returns>The column metadata as a <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> object.</returns><remarks>To be added.</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetSqlMoney(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Gets the value for the column specified by the ordinal as a <see cref="T:System.Data.SqlTypes.SqlMoney" />.</summary><returns>The column value as a <see cref="T:System.Data.SqlTypes.SqlMoney" />.</returns><remarks>To be added.</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetSqlSingle(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Gets the value for the column specified by the ordinal as a <see cref="T:System.Data.SqlTypes.SqlSingle" />.</summary><returns>The column value as a <see cref="T:System.Data.SqlTypes.SqlSingle" />.</returns><remarks>To be added.</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetSqlString(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Gets the value for the column specified by the ordinal as a <see cref="T:System.Data.SqlTypes.SqlString" />.</summary><returns>The column value as a <see cref="T:System.Data.SqlTypes.SqlString" />.</returns><remarks>To be added.</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetSqlValue(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Returns the data value stored in the column, expressed as a SQL Server type, specified by the column ordinal.</summary><returns>The value of the column, expressed as a SQL Server type, as a <see cref="T:System.Object" />.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
For null values, a SQL Server type instance is returned where the <xref:System.Data.SqlTypes.INullable.IsNull%2A> property is true.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception><altmember cref="N:System.Data.SqlTypes" />
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetSqlValues(System.Object[])">
|
||
|
<param name="values">The array into which to copy the values column values.</param><summary>Returns the values for all the columns in the record, expressed as SQL Server types, in an array.</summary><returns>An <see cref="T:System.Int32" /> that indicates the number of columns copied.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The SQL Server type values of the column are copied into the `values` array that is passed as a parameter. For null values, a Sql type instance is returned where the <xref:System.Data.SqlTypes.INullable.IsNull%2A> property is true.
|
||
|
|
||
|
The length of the `values` array does not need to match the number of columns in the record. If the array length is greater than the number of columns, all of the column values are copied into the array; if it is less, only the array length number of column values are copied into the array, starting at the column value with ordinal 0.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">
|
||
|
<paramref name="values" /> is <see langword="null" />.</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception><altmember cref="N:System.Data.SqlTypes" />
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetSqlXml(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Gets the value for the column specified by the ordinal as a <see cref="T:System.Data.SqlTypes.SqlXml" />.</summary><returns>The column value as a <see cref="T:System.Data.SqlTypes.SqlXml" />.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetString(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Gets the value for the column specified by the ordinal as a <see cref="T:System.String" />.</summary><returns>The column value as a <see cref="T:System.String" />.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetTimeSpan(System.Int32)">
|
||
|
<param name="ordinal">The zero-based column ordinal.</param><summary>Returns the specified column's data as a <see cref="T:System.TimeSpan" />.</summary><returns>The value of the specified column as a <see cref="T:System.TimeSpan" />.</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetValue(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Returns the common language runtime (CLR) type value for the column specified by the ordinal argument.</summary><returns>The CLR type value of the column specified by the ordinal.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
For columns with null value, <xref:System.DBNull.Value> is returned.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.GetValues(System.Object[])">
|
||
|
<param name="values">The array into which to copy the values column values.</param><summary>Returns the values for all the columns in the record, expressed as common language runtime (CLR) types, in an array.</summary><returns>An <see cref="T:System.Int32" /> that indicates the number of columns copied.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The CLR type values of the column are copied into the `values` array that is passed as a parameter. For columns with null value, <xref:System.DBNull.Value> is returned.
|
||
|
|
||
|
The length of the `values` array does not need to match the number of columns in the record. If the array length is greater than the number of columns, all of the column values are copied into the array; if it is less, only the array length number of column values is copied into the array, starting at the column value with ordinal 0.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">
|
||
|
<paramref name="values" /> is <see langword="null" />.</exception><exception cref="T:System.InvalidCastException">There is a type mismatch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.IsDBNull(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Returns true if the column specified by the column ordinal parameter is null.</summary><returns>
|
||
|
<see langword="true" /> if the column is null; <see langword="false" /> otherwise.</returns><remarks>To be added.</remarks><exception cref="T:System.IndexOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetBoolean(System.Int32,System.Boolean)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="value">The new value of the column.</param><summary>Sets the data stored in the column to the specified <see cref="T:System.Boolean" /> value.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetByte(System.Int32,System.Byte)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="value">The new value of the column.</param><summary>Sets the data stored in the column to the specified <see cref="T:System.Byte" /> value.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetBytes(System.Int32,System.Int64,System.Byte[],System.Int32,System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="fieldOffset">The offset into the field value to start copying bytes.</param><param name="buffer">The target buffer from which to copy bytes.</param><param name="bufferOffset">The offset into the buffer from which to start copying bytes.</param><param name="length">The number of bytes to copy from the buffer.</param><summary>Sets the data stored in the column to the specified array of <see cref="T:System.Byte" /> values.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetChar(System.Int32,System.Char)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="value">The new value of the column.</param><summary>Sets the data stored in the column to the specified <see cref="T:System.Char" /> value.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetChars(System.Int32,System.Int64,System.Char[],System.Int32,System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="fieldOffset">The offset into the field value to start copying characters.</param><param name="buffer">The target buffer from which to copy chars.</param><param name="bufferOffset">The offset into the buffer from which to start copying chars.</param><param name="length">The number of chars to copy from the buffer.</param><summary>Sets the data stored in the column to the specified array of <see cref="T:System.Char" /> values.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetDateTime(System.Int32,System.DateTime)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="value">The new value of the column.</param><summary>Sets the data stored in the column to the specified <see cref="T:System.DateTime" /> value.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetDateTimeOffset(System.Int32,System.DateTimeOffset)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="value">The new value of the column.</param><summary>Sets the value of the column specified to the <see cref="T:System.DateTimeOffset" /> value.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetDBNull(System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><summary>Sets the value in the specified column to <see cref="T:System.DBNull" />.</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetDecimal(System.Int32,System.Decimal)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="value">The new value of the column.</param><summary>Sets the data stored in the column to the specified <see cref="T:System.Decimal" /> value.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetDouble(System.Int32,System.Double)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="value">The new value of the column.</param><summary>Sets the data stored in the column to the specified <see cref="T:System.Double" /> value.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetFloat(System.Int32,System.Single)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="value">The new value of the column.</param><summary>Sets the data stored in the column to the specified <see langword="float" /> value.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetGuid(System.Int32,System.Guid)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="value">The new value of the column.</param><summary>Sets the data stored in the column to the specified <see cref="T:System.Guid" /> value.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetInt16(System.Int32,System.Int16)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="value">The new value of the column.</param><summary>Sets the data stored in the column to the specified <see cref="T:System.Int16" /> value.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetInt32(System.Int32,System.Int32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="value">The new value of the column.</param><summary>Sets the data stored in the column to the specified <see cref="T:System.Int32" /> value.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetInt64(System.Int32,System.Int64)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="value">The new value of the column.</param><summary>Sets the data stored in the column to the specified <see cref="T:System.Int64" /> value.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetSqlBinary(System.Int32,System.Data.SqlTypes.SqlBinary)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="value">The new value of the column.</param><summary>Sets the data stored in the column to the specified <see cref="T:System.Data.SqlTypes.SqlBinary" /> value.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetSqlBoolean(System.Int32,System.Data.SqlTypes.SqlBoolean)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="value">The new value of the column.</param><summary>Sets the data stored in the column to the specified <see cref="T:System.Data.SqlTypes.SqlBoolean" /> value.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetSqlByte(System.Int32,System.Data.SqlTypes.SqlByte)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="value">The new value of the column.</param><summary>Sets the data stored in the column to the specified <see cref="T:System.Data.SqlTypes.SqlByte" /> value.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetSqlBytes(System.Int32,System.Data.SqlTypes.SqlBytes)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="value">The new value of the column.</param><summary>Sets the data stored in the column to the specified <see cref="T:System.Data.SqlTypes.SqlBytes" /> value.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetSqlChars(System.Int32,System.Data.SqlTypes.SqlChars)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="value">The new value of the column.</param><summary>Sets the data stored in the column to the specified <see cref="T:System.Data.SqlTypes.SqlChars" /> value.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetSqlDateTime(System.Int32,System.Data.SqlTypes.SqlDateTime)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="value">The new value of the column.</param><summary>Sets the data stored in the column to the specified <see cref="T:System.Data.SqlTypes.SqlDateTime" /> value.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetSqlDecimal(System.Int32,System.Data.SqlTypes.SqlDecimal)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="value">The new value of the column.</param><summary>Sets the data stored in the column to the specified <see cref="T:System.Data.SqlTypes.SqlDecimal" /> value.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetSqlDouble(System.Int32,System.Data.SqlTypes.SqlDouble)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="value">The new value of the column.</param><summary>Sets the data stored in the column to the specified <see cref="T:System.Data.SqlTypes.SqlDouble" /> value.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetSqlGuid(System.Int32,System.Data.SqlTypes.SqlGuid)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="value">The new value of the column.</param><summary>Sets the data stored in the column to the specified <see cref="T:System.Data.SqlTypes.SqlGuid" /> value.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetSqlInt16(System.Int32,System.Data.SqlTypes.SqlInt16)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="value">The new value of the column.</param><summary>Sets the data stored in the column to the specified <see cref="T:System.Data.SqlTypes.SqlInt16" /> value.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetSqlInt32(System.Int32,System.Data.SqlTypes.SqlInt32)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="value">The new value of the column.</param><summary>Sets the data stored in the column to the specified <see cref="T:System.Data.SqlTypes.SqlInt32" /> value.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetSqlInt64(System.Int32,System.Data.SqlTypes.SqlInt64)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="value">The new value of the column.</param><summary>Sets the data stored in the column to the specified <see cref="T:System.Data.SqlTypes.SqlInt64" /> value.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetSqlMoney(System.Int32,System.Data.SqlTypes.SqlMoney)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="value">The new value of the column.</param><summary>Sets the data stored in the column to the specified <see cref="T:System.Data.SqlTypes.SqlMoney" /> value.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetSqlSingle(System.Int32,System.Data.SqlTypes.SqlSingle)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="value">The new value of the column.</param><summary>Sets the data stored in the column to the specified <see cref="T:System.Data.SqlTypes.SqlSingle" /> value.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetSqlString(System.Int32,System.Data.SqlTypes.SqlString)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="value">The new value of the column.</param><summary>Sets the data stored in the column to the specified <see cref="T:System.Data.SqlTypes.SqlString" /> value.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetSqlXml(System.Int32,System.Data.SqlTypes.SqlXml)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="value">The new value of the column.</param><summary>Sets the data stored in the column to the specified <see cref="T:System.Data.SqlTypes.SqlXml" /> value.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetString(System.Int32,System.String)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="value">The new value of the column.</param><summary>Sets the data stored in the column to the specified <see cref="T:System.String" /> value.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetTimeSpan(System.Int32,System.TimeSpan)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="value">The new value of the column.</param><summary>Sets the value of the column specified to the <see cref="T:System.TimeSpan" />.</summary><remarks>To be added.</remarks><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="ordinal" /> passed in is a negative number.</exception><exception cref="T:System.ArgumentException">The <see cref="T:System.TimeSpan" /> value passed in is greater than 24 hours in length.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetValue(System.Int32,System.Object)">
|
||
|
<param name="ordinal">The zero-based ordinal of the column.</param><param name="value">The new value for the specified column.</param><summary>Sets a new value, expressed as a common language runtime (CLR) type, for the column specified by the column ordinal.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
`value` is a SQL type boxed as a <xref:System.Object> instance.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentOutOfRangeException">The <paramref name="ordinal" /> is less than 0 or greater than the number of columns (that is, <see cref="P:Microsoft.Data.SqlClient.Server.SqlDataRecord.FieldCount" />).</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlDataRecord.SetValues(System.Object[])">
|
||
|
<param name="values">The array of new values, expressed as CLR types boxed as <see cref="T:System.Object" /> references, for the <see cref="T:Microsoft.Data.SqlClient.Server.SqlDataRecord" /> instance.</param><summary>Sets new values for all of the columns in the <see cref="T:Microsoft.Data.SqlClient.Server.SqlDataRecord" />. These values are expressed as common language runtime (CLR) types.</summary><returns>The number of column values set as an integer.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The length of values must match the number of columns in the <xref:Microsoft.Data.SqlClient.Server.SqlDataRecord> instance.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">
|
||
|
<paramref name="values" /> is <see langword="null" />.</exception><exception cref="T:System.ArgumentException">The size of values does not match the number of columns in the <see cref="T:Microsoft.Data.SqlClient.Server.SqlDataRecord" /> instance.</exception>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.Server.SqlMetaData">
|
||
|
<summary>Specifies and retrieves metadata information from parameters and columns of <see cref="T:Microsoft.Data.SqlClient.Server.SqlDataRecord" /> objects. This class cannot be inherited.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Examples
|
||
|
The following example shows the creation of several <xref:Microsoft.Data.SqlClient.Server.SqlMetaData> objects, which describe the column metadata of a record, and the creation of a <xref:Microsoft.Data.SqlClient.Server.SqlDataRecord>. The column values of the <xref:Microsoft.Data.SqlClient.Server.SqlDataRecord> are set and the <xref:Microsoft.Data.SqlClient.Server.SqlDataRecord> is sent to the calling program using the <xref:Microsoft.SqlServer.Server.SqlContext> class.
|
||
|
|
||
|
[!code-csharp[SqlMetaData Samples#1](~/../sqlclient/doc/samples/SqlMetaData.cs#1)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.#ctor(System.String,System.Data.SqlDbType)">
|
||
|
<param name="name">The name of the column.</param><param name="dbType">The SQL Server type of the parameter or column.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> class with the specified column name and type.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Only the following are allowed to be passed to the constructor as `dbType`: `Bit`, `BigInt`, `DateTime`, `Decimal`, `Float`, `Int`, `Money`, `Numeric`, `SmallDateTime`, `SmallInt`, `SmallMoney`, `TimeStamp`, `TinyInt`, `UniqueIdentifier`, `Xml`.
|
||
|
|
||
|
The following are the default values assigned to `dbType`, depending on the `SqlDbType` (the <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.XmlSchemaCollectionDatabase%2A>, <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.XmlSchemaCollectionName%2A>, <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.XmlSchemaCollectionOwningSchema%2A>, and <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.Type%2A> properties are set to `null`):
|
||
|
|
||
|
|SqlDbType|Maximum length|Precision|Scale|Locale|Compare options|
|
||
|
|---------------|--------------------|---------------|-----------|------------|---------------------|
|
||
|
|`Bit`|1|1|0|0|None|
|
||
|
|`BigInt`|8|19|0|0|None|
|
||
|
|`DateTime`|8|23|3|0|None|
|
||
|
|`Decimal`|9|18|0|0|None|
|
||
|
|`Float`|8|53|0|0|None|
|
||
|
|`Int`|4|10|0|0|None|
|
||
|
|`Money`|8|19|4|0|None|
|
||
|
|`Numeric`|9|18|0|0|None|
|
||
|
|`SmallDateTime`|4|16|0|0|None|
|
||
|
|`SmallInt`|2|5|0|0|None|
|
||
|
|`SmallMoney`|4|10|4|0|None|
|
||
|
|`TimeStamp`|8|0|0|0|None|
|
||
|
|`TinyInt`|1|3|0|0|None|
|
||
|
|`UniqueIdentifier`|16|0|0|0|None|
|
||
|
|`Xml`|Max (-1)|0|0|0|IgnoreCase, IgnoreKanaType, IgnoreWidth|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a new <xref:Microsoft.Data.SqlClient.Server.SqlMetaData> object by specifying the column name and a column data type of <xref:System.Data.SqlDbType>.`Int`.
|
||
|
|
||
|
[!code-csharp[SqlMetaData Samples#3](~/../sqlclient/doc/samples/SqlMetaData.cs#3)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">The <paramref name="name" /> is <see langword="null" />.</exception><exception cref="T:System.ArgumentException">A <see langword="SqlDbType" /> that is not allowed was passed to the constructor as <paramref name="dbType" />.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.#ctor(System.String,System.Data.SqlDbType,System.Boolean,System.Boolean,Microsoft.Data.SqlClient.SortOrder,System.Int32)">
|
||
|
<param name="name">The name of the column.</param><param name="dbType">The SQL Server type of the parameter or column.</param><param name="useServerDefault">Specifies whether this column should use the default server value.</param><param name="isUniqueKey">Specifies if the column in the table-valued parameter is unique.</param><param name="columnSortOrder">Specifies the sort order for a column.</param><param name="sortOrdinal">Specifies the ordinal of the sort column.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> class with the specified column name, and default server. This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
For more information, see [Table-Valued Parameters](/sql/connect/ado-net/sql/table-valued-parameters).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.#ctor(System.String,System.Data.SqlDbType,System.Byte,System.Byte)">
|
||
|
<param name="name">The name of the parameter or column.</param><param name="dbType">The SQL Server type of the parameter or column.</param><param name="precision">The precision of the parameter or column.</param><param name="scale">The scale of the parameter or column.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> class with the specified column name, type, precision, and scale.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Only the following `SqlDbType` is allowed to be passed to the constructor as `dbType`: `Decimal`.
|
||
|
|
||
|
The following are the default values assigned to `dbType`, depending on the `SqlDbType` (the <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.XmlSchemaCollectionDatabase%2A>, <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.XmlSchemaCollectionName%2A>, <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.XmlSchemaCollectionOwningSchema%2A>, and <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.Type%2A> properties are set to `null`):
|
||
|
|
||
|
|SqlDbType|Maximum length|Precision|Scale|Locale|Compare options|
|
||
|
|---------------|--------------------|---------------|-----------|------------|---------------------|
|
||
|
|Decimal|9|18|0|0|None|
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">The <paramref name="name" /> is <see langword="null" />.</exception><exception cref="T:System.ArgumentException">A <see langword="SqlDbType" /> that is not allowed was passed to the constructor as <paramref name="dbType" />, or <paramref name="scale" /> was greater than <paramref name="precision" />.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.#ctor(System.String,System.Data.SqlDbType,System.Byte,System.Byte,System.Boolean,System.Boolean,Microsoft.Data.SqlClient.SortOrder,System.Int32)">
|
||
|
<param name="name">The name of the column.</param><param name="dbType">The SQL Server type of the parameter or column.</param><param name="precision">The precision of the parameter or column.</param><param name="scale">The scale of the parameter or column.</param><param name="useServerDefault">Specifies whether this column should use the default server value.</param><param name="isUniqueKey">Specifies if the column in the table-valued parameter is unique.</param><param name="columnSortOrder">Specifies the sort order for a column.</param><param name="sortOrdinal">Specifies the ordinal of the sort column.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> class with the specified column name, type, precision, scale, and server default. This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
For more information, see [Table-Valued Parameters](/sql/connect/ado-net/sql/table-valued-parameters).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.#ctor(System.String,System.Data.SqlDbType,System.Int64)">
|
||
|
<param name="name">The name of the column.</param><param name="dbType">The SQL Server type of the parameter or column.</param><param name="maxLength">The maximum length of the specified type.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> class with the specified column name, type, and maximum length.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Only the following are allowed to be passed to the constructor as `dbType`: `Binary`, `Char`, `Image`, `NChar`, `Ntext`, `NVarChar`, `Text`, `VarBinary`, `VarChar`.
|
||
|
|
||
|
Only a `maxLength` specification of <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.Max%2A>, or -1 is allowed for a `dbType` of `Text`, `NText`, or `Image`.
|
||
|
|
||
|
For a `dbType` of `Varchar`, `Nvarchar`, or `VarBinary`, a length specification of <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.Max%2A>, or -1, declares the metadata as varchar(max), nvarchar(max), or nvarbinary(max), respectively.
|
||
|
|
||
|
The following are the default values assigned to `dbType`, depending on the `SqlDbType` (the <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.XmlSchemaCollectionDatabase%2A>, <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.XmlSchemaCollectionName%2A>, <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.XmlSchemaCollectionOwningSchema%2A>, and <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.Type%2A> properties are set to `null`):
|
||
|
|
||
|
|SqlDbType|Precision|Scale|Locale|Compare options|
|
||
|
|---------------|---------------|-----------|------------|---------------------|
|
||
|
|Binary|0|0|0|IgnoreCase, IgnoreKanaType, IgnoreWidth|
|
||
|
|Char|0|0|\<thread>|IgnoreCase, IgnoreKanaType, IgnoreWidth|
|
||
|
|Image|0|0|0|None|
|
||
|
|NChar|0|0|\<thread>|IgnoreCase, IgnoreKanaType, IgnoreWidth|
|
||
|
|NText|0|0|\<thread>|IgnoreCase, IgnoreKanaType, IgnoreWidth|
|
||
|
|NVarChar|0|0|\<thread>|IgnoreCase, IgnoreKanaType, IgnoreWidth|
|
||
|
|Text|0|0|\<thread>|IgnoreCase, IgnoreKanaType, IgnoreWidth|
|
||
|
|VarBinary|0|0||IgnoreCase, IgnoreKanaType, IgnoreWidth|
|
||
|
|VarChar|0|0|\<thread>|IgnoreCase, IgnoreKanaType, IgnoreWidth|
|
||
|
|
||
|
|
||
|
## Examples
|
||
|
The following example creates a new <xref:Microsoft.Data.SqlClient.Server.SqlMetaData> object by specifying the column name, a column data type of <xref:System.Data.SqlDbType>`.NVarChar`, and a maximum length of 12 characters.
|
||
|
|
||
|
[!code-csharp[SqlMetaData Samples#2](~/../sqlclient/doc/samples/SqlMetaData.cs#2)]
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">The <paramref name="name" /> is <see langword="null" />.</exception><exception cref="T:System.ArgumentException">A SqlDbType that is not allowed was passed to the constructor as <paramref name="dbType" />.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.#ctor(System.String,System.Data.SqlDbType,System.Int64,System.Boolean,System.Boolean,Microsoft.Data.SqlClient.SortOrder,System.Int32)">
|
||
|
<param name="name">The name of the column.</param><param name="dbType">The SQL Server type of the parameter or column.</param><param name="maxLength">The maximum length of the specified type.</param><param name="useServerDefault">Specifies whether this column should use the default server value.</param><param name="isUniqueKey">Specifies if the column in the table-valued parameter is unique.</param><param name="columnSortOrder">Specifies the sort order for a column.</param><param name="sortOrdinal">Specifies the ordinal of the sort column.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> class with the specified column name, type, maximum length, and server default. This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
For more information, see [Table-Valued Parameters](/sql/connect/ado-net/sql/table-valued-parameters).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.#ctor(System.String,System.Data.SqlDbType,System.Int64,System.Byte,System.Byte,System.Int64,System.Data.SqlTypes.SqlCompareOptions,System.Type)">
|
||
|
<param name="name">The name of the column.</param><param name="dbType">The SQL Server type of the parameter or column.</param><param name="maxLength">The maximum length of the specified type.</param><param name="precision">The precision of the parameter or column.</param><param name="scale">The scale of the parameter or column.</param><param name="locale">The locale ID of the parameter or column.</param><param name="compareOptions">The comparison rules of the parameter or column.</param><param name="userDefinedType">A <see cref="T:System.Type" /> instance that points to the UDT.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> class with the specified column name, type, maximum length, precision, scale, locale ID, compare options, and user-defined type (UDT).</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Only the following are allowed to be passed to the constructor as `dbType`: `BigInt`, `Bit`, `BitInt`, `DateTime`, `Decimal`, `Float`, `Image`, `Int`, `Money`, `Ntext`, `Numeric`, `Real`, `SmallDateTime`, `SmallInt`, `SmallMoney`, `Text`, `TimeStamp`, `TinyInt`, `UniqueIdentifier`, `Variant`, `Xml`.
|
||
|
|
||
|
The following are the default values assigned to `dbType`, depending on the `SqlDbType` (the <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.XmlSchemaCollectionDatabase%2A>, <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.XmlSchemaCollectionName%2A>, <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.XmlSchemaCollectionOwningSchema%2A>, and <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.Type%2A> properties are set to `null`):
|
||
|
|
||
|
|SqlDbType|Maximum length|Precision|Scale|Locale|Compare options|
|
||
|
|---------------|--------------------|---------------|-----------|------------|---------------------|
|
||
|
|`BigInt`|8|19|0|0|None|
|
||
|
|`Bit`|1|1|0|0|None|
|
||
|
|`DateTime`|8|23|3|0|None|
|
||
|
|`Decimal`|9|18|0|0|None|
|
||
|
|`Float`|8|53|0|0|None|
|
||
|
|`Image`|Max (-1)|0|0|0|None|
|
||
|
|`Int`|4|10|0|0|None|
|
||
|
|`Money`|8|19|4|0|None|
|
||
|
|`Ntext`|Max (-1)|0|0|\<thread>|IgnoreCase, IgnoreKanaType, IgnoreWidth|
|
||
|
|`Real`|4|24|0|0|None|
|
||
|
|`Row`|\<number of columns>|0|0|0|None|
|
||
|
|`SmallDateTime`|4|16|0|0|None|
|
||
|
|`SmallInt`|2|5|0|0|None|
|
||
|
|`SmallMoney`|4|10|4|0|None|
|
||
|
|`Text`|Max (-1)|0|0|\<thread>|IgnoreCase, IgnoreKanaType, IgnoreWidth|
|
||
|
|`TimeStamp`|8|0|0|0|None|
|
||
|
|`TinyInt`|1|3|0|0|None|
|
||
|
|`UniqueIdentifier`|16|0|0|0|None|
|
||
|
|`UDT`|\<Max length of the type> or -1|0|0|0|None|
|
||
|
|`Variant`|8016|0|0|0|None|
|
||
|
|`Xml`|Max (-1)|0|0|0|IgnoreCase, IgnoreKanaType, IgnoreWidth|
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">The <paramref name="name" /> is <see langword="null" />.</exception><exception cref="T:System.ArgumentException">A <see langword="SqlDbType" /> that is not allowed was passed to the constructor as <paramref name="dbType" />, or <paramref name="userDefinedType" /> points to a type that does not have <see cref="T:Microsoft.Data.SqlClient.Server.SqlUserDefinedTypeAttribute" /> declared.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.#ctor(System.String,System.Data.SqlDbType,System.Int64,System.Byte,System.Byte,System.Int64,System.Data.SqlTypes.SqlCompareOptions,System.Type,System.Boolean,System.Boolean,Microsoft.Data.SqlClient.SortOrder,System.Int32)">
|
||
|
<param name="name">The name of the column.</param><param name="dbType">The SQL Server type of the parameter or column.</param><param name="maxLength">The maximum length of the specified type.</param><param name="precision">The precision of the parameter or column.</param><param name="scale">The scale of the parameter or column.</param><param name="localeId">The locale ID of the parameter or column.</param><param name="compareOptions">The comparison rules of the parameter or column.</param><param name="userDefinedType">A <see cref="T:System.Type" /> instance that points to the UDT.</param><param name="useServerDefault">Specifies whether this column should use the default server value.</param><param name="isUniqueKey">Specifies if the column in the table-valued parameter is unique.</param><param name="columnSortOrder">Specifies the sort order for a column.</param><param name="sortOrdinal">Specifies the ordinal of the sort column.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> class with the specified column name, type, maximum length, precision, scale, locale ID, compare options, and user-defined type (UDT). This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
For more information, see [Table-Valued Parameters](/sql/connect/ado-net/sql/table-valued-parameters).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.#ctor(System.String,System.Data.SqlDbType,System.Int64,System.Int64,System.Data.SqlTypes.SqlCompareOptions)">
|
||
|
<param name="name">The name of the parameter or column.</param><param name="dbType">The SQL Server type of the parameter or column.</param><param name="maxLength">The maximum length of the specified type.</param><param name="locale">The locale ID of the parameter or column.</param><param name="compareOptions">The comparison rules of the parameter or column.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> class with the specified column name, type, maximum length, locale, and compare options.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Only the following are allowed to be passed to the constructor as `dbType`: `Char`, `NChar`, `Ntext`, `NVarChar`, `Text`, `VarChar`.
|
||
|
|
||
|
Only a `maxLength` specification of <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.Max%2A>, or -1, is allowed for a `dbType` of `Text` or `NText`.
|
||
|
|
||
|
For a `dbType` of `Varchar` or `Nvarchar`, a length specification of <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.Max%2A>, or -1, declares the metadata as varchar(max) and nvarchar(max), respectively.
|
||
|
|
||
|
The following are the default values assigned to `dbType`, depending on the `SqlDbType` (the <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.XmlSchemaCollectionDatabase%2A>, <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.XmlSchemaCollectionName%2A>, <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.XmlSchemaCollectionOwningSchema%2A>, and <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.Type%2A> properties are set to `null`):
|
||
|
|
||
|
|SqlDbType|Precision|Scale|
|
||
|
|---------------|---------------|-----------|
|
||
|
|`Char`|0|0|
|
||
|
|`NChar`|0|0|
|
||
|
|`NText`|0|0|
|
||
|
|`NVarChar`|0|0|
|
||
|
|`Text`|0|0|
|
||
|
|`VarChar`|0|0|
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">The <paramref name="name" /> is <see langword="null" />.</exception><exception cref="T:System.ArgumentException">A SqlDbType that is not allowed was passed to the constructor as <paramref name="dbType" />.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.#ctor(System.String,System.Data.SqlDbType,System.Int64,System.Int64,System.Data.SqlTypes.SqlCompareOptions,System.Boolean,System.Boolean,Microsoft.Data.SqlClient.SortOrder,System.Int32)">
|
||
|
<param name="name">The name of the column.</param><param name="dbType">The SQL Server type of the parameter or column.</param><param name="maxLength">The maximum length of the specified type.</param><param name="locale">The locale ID of the parameter or column.</param><param name="compareOptions">The comparison rules of the parameter or column.</param><param name="useServerDefault">Specifies whether this column should use the default server value.</param><param name="isUniqueKey">Specifies if the column in the table-valued parameter is unique.</param><param name="columnSortOrder">Specifies the sort order for a column.</param><param name="sortOrdinal">Specifies the ordinal of the sort column.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> class with the specified column name, type, maximum length, locale, compare options, and server default. This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
For more information, see [Table-Valued Parameters](/sql/connect/ado-net/sql/table-valued-parameters).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.#ctor(System.String,System.Data.SqlDbType,System.String,System.String,System.String)">
|
||
|
<param name="name">The name of the column.</param><param name="dbType">The SQL Server type of the parameter or column.</param><param name="database">The database name of the XML schema collection of a typed XML instance.</param><param name="owningSchema">The relational schema name of the XML schema collection of a typed XML instance.</param><param name="objectName">The name of the XML schema collection of a typed XML instance.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> class with the specified column name, type, database name, owning schema, and object name.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Only the following `SqlDbType` is allowed to be passed to the constructor as `dbType`: `Xml`.
|
||
|
|
||
|
The following are the default values assigned to `dbType`, depending on the `SqlDbType`:
|
||
|
|
||
|
|SqlDbType|Maximum length|Precision|Scale|Locale|Compare options|
|
||
|
|---------------|--------------------|---------------|-----------|------------|---------------------|
|
||
|
|`Xml`|Max (-1)|0|0|0|IgnoreCase, IgnoreKanaType, IgnoreWidth|
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">The <paramref name="name" /> is <see langword="null" />, or <paramref name="objectName" /> is <see langword="null" /> when <paramref name="database" /> and <paramref name="owningSchema" /> are non-<see langword="null" />.</exception><exception cref="T:System.ArgumentException">A SqlDbType that is not allowed was passed to the constructor as <paramref name="dbType" />.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.#ctor(System.String,System.Data.SqlDbType,System.String,System.String,System.String,System.Boolean,System.Boolean,Microsoft.Data.SqlClient.SortOrder,System.Int32)">
|
||
|
<param name="name">The name of the column.</param><param name="dbType">The SQL Server type of the parameter or column.</param><param name="database">The database name of the XML schema collection of a typed XML instance.</param><param name="owningSchema">The relational schema name of the XML schema collection of a typed XML instance.</param><param name="objectName">The name of the XML schema collection of a typed XML instance.</param><param name="useServerDefault">Specifies whether this column should use the default server value.</param><param name="isUniqueKey">Specifies if the column in the table-valued parameter is unique.</param><param name="columnSortOrder">Specifies the sort order for a column.</param><param name="sortOrdinal">Specifies the ordinal of the sort column.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> class with the specified column name, database name, owning schema, object name, and default server. This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
For more information, see [Table-Valued Parameters](/sql/connect/ado-net/sql/table-valued-parameters).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.#ctor(System.String,System.Data.SqlDbType,System.Type)">
|
||
|
<param name="name">The name of the column.</param><param name="dbType">The SQL Server type of the parameter or column.</param><param name="userDefinedType">A <see cref="T:System.Type" /> instance that points to the UDT.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> class with the specified column name, type, and user-defined type (UDT).</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Only the following `SqlDbType` is allowed to be passed to the constructor as `dbType`: `UDT`.
|
||
|
|
||
|
The following are the default values assigned to `dbType`, depending on the `SqlDbType` (the <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.XmlSchemaCollectionDatabase%2A>, <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.XmlSchemaCollectionName%2A>, <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.XmlSchemaCollectionOwningSchema%2A>, and <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.Type%2A> properties are set to `null`):
|
||
|
|
||
|
|SqlDbType|Maximum length|Precision|Scale|Locale|Compare options|
|
||
|
|---------------|--------------------|---------------|-----------|------------|---------------------|
|
||
|
|UDT|\<Max length of the type> or -1|0|0|0|None|
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.ArgumentNullException">The <paramref name="name" /> is <see langword="null" />.</exception><exception cref="T:System.ArgumentException">A SqlDbType that is not allowed was passed to the constructor as <paramref name="dbType" />, or <paramref name="userDefinedType" /> points to a type that does not have <see cref="T:Microsoft.Data.SqlClient.Server.SqlUserDefinedTypeAttribute" /> declared.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.#ctor(System.String,System.Data.SqlDbType,System.Type,System.String)">
|
||
|
<param name="name">The name of the column.</param><param name="dbType">The SQL Server type of the parameter or column.</param><param name="userDefinedType">A <see cref="T:System.Type" /> instance that points to the UDT.</param><param name="serverTypeName">The SQL Server type name for <paramref name="userDefinedType" />.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> class with the specified column name, user-defined type (UDT), and SQLServer type.</summary>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.#ctor(System.String,System.Data.SqlDbType,System.Type,System.String,System.Boolean,System.Boolean,Microsoft.Data.SqlClient.SortOrder,System.Int32)">
|
||
|
<param name="name">The name of the column.</param><param name="dbType">The SQL Server type of the parameter or column.</param><param name="userDefinedType">A <see cref="T:System.Type" /> instance that points to the UDT.</param><param name="serverTypeName">The SQL Server type name for <paramref name="userDefinedType" />.</param><param name="useServerDefault">Specifies whether this column should use the default server value.</param><param name="isUniqueKey">Specifies if the column in the table-valued parameter is unique.</param><param name="columnSortOrder">Specifies the sort order for a column.</param><param name="sortOrdinal">Specifies the ordinal of the sort column.</param><summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> class with the specified column name, type, user-defined type, SQL Server type, and server default. This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
For more information, see [Table-Valued Parameters](/sql/connect/ado-net/sql/table-valued-parameters).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.Server.SqlMetaData.CompareOptions">
|
||
|
<summary>Gets the comparison rules used for the column or parameter.</summary><value>The comparison rules used for the column or parameter as a <see cref="T:System.Data.SqlTypes.SqlCompareOptions" />.</value><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.Server.SqlMetaData.DbType">
|
||
|
<summary>Gets the data type of the column or parameter.</summary><value>The data type of the column or parameter as a <see cref="T:System.Data.DbType" />.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The default type is <xref:System.Data.DbType>.`String`.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.Server.SqlMetaData.IsUniqueKey">
|
||
|
<summary>Indicates if the column in the table-valued parameter is unique.</summary><value>A <see langword="Boolean" /> value.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The default is `FALSE`.
|
||
|
|
||
|
This property can only be set in one of the <xref:Microsoft.Data.SqlClient.Server.SqlMetaData> constructors.
|
||
|
|
||
|
For more information, see [Table-Valued Parameters](/sql/connect/ado-net/sql/table-valued-parameters).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.Server.SqlMetaData.LocaleId">
|
||
|
<summary>Gets the locale ID of the column or parameter.</summary><value>The locale ID of the column or parameter as a <see cref="T:System.Int64" />.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The default value is the current locale of the current thread for string-valued SqlDbTypes, and 0 for SqlDbTypes that do not support collation.
|
||
|
|
||
|
Returns 0 if the collation of the underlying column type is not defined.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.Server.SqlMetaData.Max">
|
||
|
<summary>Gets the length of <see langword="text" />, <see langword="ntext" />, and <see langword="image" /> data types.</summary><value>The length of <see langword="text" />, <see langword="ntext" />, and <see langword="image" /> data types.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The default value is -1.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.Server.SqlMetaData.MaxLength">
|
||
|
<summary>Gets the maximum length of the column or parameter.</summary><value>The maximum length of the column or parameter as a <see cref="T:System.Int64" />.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The potential maximum length for values of the specified column. Returns 0 for types other than fixed and varying length character and binary types. For variable size columns or parameters declared with the `Max` constructor parameter, it returns -1.
|
||
|
|
||
|
For <xref:System.Data.DbType>.`Row` this returns the number of columns in the row metadata instance.
|
||
|
|
||
|
The default value is 0.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.Server.SqlMetaData.Name">
|
||
|
<summary>Gets the name of the column or parameter.</summary><value>The name of the column or parameter as a <see cref="T:System.String" />.</value><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.Server.SqlMetaData.Precision">
|
||
|
<summary>Gets the precision of the column or parameter.</summary><value>The precision of the column or parameter as a <see cref="T:System.Byte" />.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Returns 0 if the precision of the underlying column type is not defined.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.Server.SqlMetaData.Scale">
|
||
|
<summary>Gets the scale of the column or parameter.</summary><value>The scale of the column or parameter.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
Returns 0 if the scale of the underlying column type is not defined.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.Server.SqlMetaData.SortOrder">
|
||
|
<summary>Returns the sort order for a column.</summary><value>A <see cref="T:Microsoft.Data.SqlClient.SortOrder" /> object.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
This property can only be set in one of the <xref:Microsoft.Data.SqlClient.Server.SqlMetaData> constructors.
|
||
|
|
||
|
For more information, see [Table-Valued Parameters](/sql/connect/ado-net/sql/table-valued-parameters).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.Server.SqlMetaData.SortOrdinal">
|
||
|
<summary>Returns the ordinal of the sort column.</summary><value>The ordinal of the sort column.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The default is 1.
|
||
|
|
||
|
This property can only be set in one of the <xref:Microsoft.Data.SqlClient.Server.SqlMetaData> constructors.
|
||
|
|
||
|
For more information, see [Table-Valued Parameters](/sql/connect/ado-net/sql/table-valued-parameters).
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.Server.SqlMetaData.SqlDbType">
|
||
|
<summary>Gets the data type of the column or parameter.</summary><value>The data type of the column or parameter as a <see cref="T:System.Data.DbType" />.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The default value is `NVarChar`.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.Server.SqlMetaData.Type">
|
||
|
<summary>Gets the common language runtime (CLR) type of a user-defined type (UDT).</summary><value>The CLR type name of a user-defined type as a <see cref="T:System.Type" />.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The default value is `null`.
|
||
|
|
||
|
Returns `null` if <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.SqlDbType%2A> is not a UDT type. `Null` may also returned for valid UDT result sets where the assembly is not available to the application.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.Server.SqlMetaData.TypeName">
|
||
|
<summary>Gets the three-part name of the user-defined type (UDT) or the SQL Server type represented by the instance.</summary><value>The name of the UDT or SQL Server type as a <see cref="T:System.String" />.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The default value is `null`.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.Server.SqlMetaData.UseServerDefault">
|
||
|
<summary>Reports whether this column should use the default server value.</summary><value>A <see langword="Boolean" /> value.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The default is `FALSE`.
|
||
|
|
||
|
This property can only be set in one of the <xref:Microsoft.Data.SqlClient.Server.SqlMetaData> constructors.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.Server.SqlMetaData.XmlSchemaCollectionDatabase">
|
||
|
<summary>Gets the name of the database where the schema collection for this XML instance is located.</summary><value>The name of the database where the schema collection for this XML instance is located as a <see cref="T:System.String" />.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The default value is `null`.
|
||
|
|
||
|
This property may be `null` if the collection is defined within the current database. It is also `null` if there is no schema collection, in which case <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.XmlSchemaCollectionName%2A> and <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.XmlSchemaCollectionOwningSchema%2A> are also null.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.Server.SqlMetaData.XmlSchemaCollectionName">
|
||
|
<summary>Gets the name of the schema collection for this XML instance.</summary><value>The name of the schema collection for this XML instance as a <see cref="T:System.String" />.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The default value is `null`.
|
||
|
|
||
|
This value is `null` if there is no associated schema collection. If the value is `null`, then <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.XmlSchemaCollectionDatabase%2A> and <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.XmlSchemaCollectionOwningSchema%2A> are also `null`.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.Server.SqlMetaData.XmlSchemaCollectionOwningSchema">
|
||
|
<summary>Gets the owning relational schema where the schema collection for this XML instance is located.</summary><value>The owning relational schema where the schema collection for this XML instance is located as a <see cref="T:System.String" />.</value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
The default value is `null`.
|
||
|
|
||
|
This value may be `null` if the collection is defined within the current database and default schema. It is also null if there is no schema collection, in which case <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.XmlSchemaCollectionDatabase%2A> and <xref:Microsoft.Data.SqlClient.Server.SqlMetaData.XmlSchemaCollectionName%2A> are also `null`.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.Adjust(System.Boolean)">
|
||
|
<param name="value">The value to validate against the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</param><summary>Validates the specified <see cref="T:System.Boolean" /> value against the metadata, and adjusts the value if necessary.</summary><returns>The adjusted value as a <see cref="T:System.Boolean" />.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="value" /> does not match the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> type, or <paramref name="value" /> could not be adjusted.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.Adjust(System.Byte)">
|
||
|
<param name="value">The value to validate against the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</param><summary>Validates the specified <see cref="T:System.Byte" /> value against the metadata, and adjusts the value if necessary.</summary><returns>The adjusted value as a <see cref="T:System.Byte" />.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="value" /> does not match the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> type, or <paramref name="value" /> could not be adjusted.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.Adjust(System.Byte[])">
|
||
|
<param name="value">The value to validate against the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</param><summary>Validates the specified array of <see cref="T:System.Byte" /> values against the metadata, and adjusts the value if necessary.</summary><returns>The adjusted value as an array of <see cref="T:System.Byte" /> values.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="value" /> does not match the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> type, or <paramref name="value" /> could not be adjusted.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.Adjust(System.Char)">
|
||
|
<param name="value">The value to validate against the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</param><summary>Validates the specified <see cref="T:System.Char" /> value against the metadata, and adjusts the value if necessary.</summary><returns>The adjusted value as a <see cref="T:System.Char" />.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="value" /> does not match the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> type, or <paramref name="value" /> could not be adjusted.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.Adjust(System.Char[])">
|
||
|
<param name="value">The value to validate against the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</param><summary>Validates the specified array of <see cref="T:System.Char" /> values against the metadata, and adjusts the value if necessary.</summary><returns>The adjusted value as an array <see cref="T:System.Char" /> values.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="value" /> does not match the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> type, or <paramref name="value" /> could not be adjusted.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.Adjust(System.Data.SqlTypes.SqlBinary)">
|
||
|
<param name="value">The value to validate against the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</param><summary>Validates the specified <see cref="T:System.Data.SqlTypes.SqlBinary" /> value against the metadata, and adjusts the value if necessary.</summary><returns>The adjusted value as a <see cref="T:System.Data.SqlTypes.SqlBinary" />.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="value" /> does not match the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> type, or <paramref name="value" /> could not be adjusted.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.Adjust(System.Data.SqlTypes.SqlBoolean)">
|
||
|
<param name="value">The value to validate against the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</param><summary>Validates the specified <see cref="T:System.Data.SqlTypes.SqlBoolean" /> value against the metadata, and adjusts the value if necessary.</summary><returns>The adjusted value as a <see cref="T:System.Data.SqlTypes.SqlBoolean" />.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="value" /> does not match the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> type, or <paramref name="value" /> could not be adjusted.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.Adjust(System.Data.SqlTypes.SqlByte)">
|
||
|
<param name="value">The value to validate against the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</param><summary>Validates the specified <see cref="T:System.Data.SqlTypes.SqlByte" /> value against the metadata, and adjusts the value if necessary.</summary><returns>The adjusted value as a <see cref="T:System.Data.SqlTypes.SqlByte" />.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="value" /> does not match the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> type, or <paramref name="value" /> could not be adjusted.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.Adjust(System.Data.SqlTypes.SqlBytes)">
|
||
|
<param name="value">The value to validate against the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</param><summary>Validates the specified <see cref="T:System.Data.SqlTypes.SqlBytes" /> value against the metadata, and adjusts the value if necessary.</summary><returns>The adjusted value as a <see cref="T:System.Data.SqlTypes.SqlBytes" />.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="value" /> does not match the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> type, or <paramref name="value" /> could not be adjusted.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.Adjust(System.Data.SqlTypes.SqlChars)">
|
||
|
<param name="value">The value to validate against the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</param><summary>Validates the specified <see cref="T:System.Data.SqlTypes.SqlChars" /> value against the metadata, and adjusts the value if necessary.</summary><returns>The adjusted value as a <see cref="T:System.Data.SqlTypes.SqlChars" />.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="value" /> does not match the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> type, or <paramref name="value" /> could not be adjusted.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.Adjust(System.Data.SqlTypes.SqlDateTime)">
|
||
|
<param name="value">The value to validate against the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</param><summary>Validates the specified <see cref="T:System.Data.SqlTypes.SqlDateTime" /> value against the metadata, and adjusts the value if necessary.</summary><returns>The adjusted value as a <see cref="T:System.Data.SqlTypes.SqlDateTime" />.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="value" /> does not match the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> type, or <paramref name="value" /> could not be adjusted.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.Adjust(System.Data.SqlTypes.SqlDecimal)">
|
||
|
<param name="value">The value to validate against the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</param><summary>Validates the specified <see cref="T:System.Data.SqlTypes.SqlDecimal" /> value against the metadata, and adjusts the value if necessary.</summary><returns>The adjusted value as a <see cref="T:System.Data.SqlTypes.SqlDecimal" />.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="value" /> does not match the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> type, or <paramref name="value" /> could not be adjusted.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.Adjust(System.Data.SqlTypes.SqlDouble)">
|
||
|
<param name="value">The value to validate against the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</param><summary>Validates the specified <see cref="T:System.Data.SqlTypes.SqlDouble" /> value against the metadata, and adjusts the value if necessary.</summary><returns>The adjusted value as a <see cref="T:System.Data.SqlTypes.SqlDouble" />.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="value" /> does not match the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> type, or <paramref name="value" /> could not be adjusted.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.Adjust(System.Data.SqlTypes.SqlGuid)">
|
||
|
<param name="value">The value to validate against the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</param><summary>Validates the specified <see cref="T:System.Data.SqlTypes.SqlGuid" /> value against the metadata, and adjusts the value if necessary.</summary><returns>The adjusted value as a <see cref="T:System.Data.SqlTypes.SqlGuid" />.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="value" /> does not match the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> type, or <paramref name="value" /> could not be adjusted.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.Adjust(System.Data.SqlTypes.SqlInt16)">
|
||
|
<param name="value">The value to validate against the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</param><summary>Validates the specified <see cref="T:System.Data.SqlTypes.SqlInt16" /> value against the metadata, and adjusts the value if necessary.</summary><returns>The adjusted value as a <see cref="T:System.Data.SqlTypes.SqlInt16" />.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="value" /> does not match the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> type, or <paramref name="value" /> could not be adjusted.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.Adjust(System.Data.SqlTypes.SqlInt32)">
|
||
|
<param name="value">The value to validate against the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</param><summary>Validates the specified <see cref="T:System.Data.SqlTypes.SqlInt32" /> value against the metadata, and adjusts the value if necessary.</summary><returns>The adjusted value as a <see cref="T:System.Data.SqlTypes.SqlInt32" />.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="value" /> does not match the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> type, or <paramref name="value" /> could not be adjusted.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.Adjust(System.Data.SqlTypes.SqlInt64)">
|
||
|
<param name="value">The value to validate against the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</param><summary>Validates the specified <see cref="T:System.Data.SqlTypes.SqlInt64" /> value against the metadata, and adjusts the value if necessary.</summary><returns>The adjusted value as a <see cref="T:System.Data.SqlTypes.SqlInt64" />.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="value" /> does not match the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> type, or <paramref name="value" /> could not be adjusted.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.Adjust(System.Data.SqlTypes.SqlMoney)">
|
||
|
<param name="value">The value to validate against the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</param><summary>Validates the specified <see cref="T:System.Data.SqlTypes.SqlMoney" /> value against the metadata, and adjusts the value if necessary.</summary><returns>The adjusted value as a <see cref="T:System.Data.SqlTypes.SqlMoney" />.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="value" /> does not match the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> type, or <paramref name="value" /> could not be adjusted.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.Adjust(System.Data.SqlTypes.SqlSingle)">
|
||
|
<param name="value">The value to validate against the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</param><summary>Validates the specified <see cref="T:System.Data.SqlTypes.SqlSingle" /> value against the metadata, and adjusts the value if necessary.</summary><returns>The adjusted value as a <see cref="T:System.Data.SqlTypes.SqlSingle" />.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="value" /> does not match the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> type, or <paramref name="value" /> could not be adjusted.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.Adjust(System.Data.SqlTypes.SqlString)">
|
||
|
<param name="value">The value to validate against the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</param><summary>Validates the specified <see cref="T:System.Data.SqlTypes.SqlString" /> value against the metadata, and adjusts the value if necessary.</summary><returns>The adjusted value as a <see cref="T:System.Data.SqlTypes.SqlString" />.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="value" /> does not match the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> type, or <paramref name="value" /> could not be adjusted.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.Adjust(System.Data.SqlTypes.SqlXml)">
|
||
|
<param name="value">The value to validate against the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</param><summary>Validates the specified <see cref="T:System.Data.SqlTypes.SqlXml" /> value against the metadata, and adjusts the value if necessary.</summary><returns>The adjusted value as a <see cref="T:System.Data.SqlTypes.SqlXml" />.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="value" /> does not match the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> type, or <paramref name="value" /> could not be adjusted.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.Adjust(System.DateTime)">
|
||
|
<param name="value">The value to validate against the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</param><summary>Validates the specified <see cref="T:System.DateTime" /> value against the metadata, and adjusts the value if necessary.</summary><returns>The adjusted value as a <see cref="T:System.DateTime" />.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="value" /> does not match the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> type, or <paramref name="value" /> could not be adjusted.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.Adjust(System.DateTimeOffset)">
|
||
|
<param name="value">The value to validate against the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</param><summary>Validates the specified <see cref="T:System.DateTimeOffset" /> value against the metadata, and adjusts the value if necessary.</summary><returns>The adjusted value as an array of <see cref="T:System.DateTimeOffset" /> values.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="value" /> does not match the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> type, or <paramref name="value" /> could not be adjusted.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.Adjust(System.Decimal)">
|
||
|
<param name="value">The value to validate against the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</param><summary>Validates the specified <see cref="T:System.Decimal" /> value against the metadata, and adjusts the value if necessary.</summary><returns>The adjusted value as a <see cref="T:System.Decimal" />.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="value" /> does not match the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> type, or <paramref name="value" /> could not be adjusted.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.Adjust(System.Double)">
|
||
|
<param name="value">The value to validate against the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</param><summary>Validates the specified <see cref="T:System.Double" /> value against the metadata, and adjusts the value if necessary.</summary><returns>The adjusted value as a <see cref="T:System.Double" />.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="value" /> does not match the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> type, or <paramref name="value" /> could not be adjusted.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.Adjust(System.Guid)">
|
||
|
<param name="value">The value to validate against the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</param><summary>Validates the specified <see cref="T:System.Guid" /> value against the metadata, and adjusts the value if necessary.</summary><returns>The adjusted value as a <see cref="T:System.Guid" />.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="value" /> does not match the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> type, or <paramref name="value" /> could not be adjusted.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.Adjust(System.Int16)">
|
||
|
<param name="value">The value to validate against the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</param><summary>Validates the specified <see cref="T:System.Int16" /> value against the metadata, and adjusts the value if necessary.</summary><returns>The adjusted value as a <see cref="T:System.Int16" />.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="value" /> does not match the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> type, or <paramref name="value" /> could not be adjusted.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.Adjust(System.Int32)">
|
||
|
<param name="value">The value to validate against the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</param><summary>Validates the specified <see cref="T:System.Int32" /> value against the metadata, and adjusts the value if necessary.</summary><returns>The adjusted value as a <see cref="T:System.Int32" />.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="value" /> does not match the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> type, or <paramref name="value" /> could not be adjusted.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.Adjust(System.Int64)">
|
||
|
<param name="value">The value to validate against the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</param><summary>Validates the specified <see cref="T:System.Int64" /> value against the metadata, and adjusts the value if necessary.</summary><returns>The adjusted value as a <see cref="T:System.Int64" />.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="value" /> does not match the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> type, or <paramref name="value" /> could not be adjusted.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.Adjust(System.Object)">
|
||
|
<param name="value">The value to validate against the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</param><summary>Validates the specified <see cref="T:System.Object" /> value against the metadata, and adjusts the value if necessary.</summary><returns>The adjusted value as a <see cref="T:System.Object" />.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="value" /> does not match the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> type, or <paramref name="value" /> could not be adjusted.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.Adjust(System.Single)">
|
||
|
<param name="value">The value to validate against the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</param><summary>Validates the specified <see cref="T:System.Single" /> value against the metadata, and adjusts the value if necessary.</summary><returns>The adjusted value as a <see cref="T:System.Single" />.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="value" /> does not match the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> type, or <paramref name="value" /> could not be adjusted.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.Adjust(System.String)">
|
||
|
<param name="value">The value to validate against the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</param><summary>Validates the specified <see cref="T:System.String" /> value against the metadata, and adjusts the value if necessary.</summary><returns>The adjusted value as a <see cref="T:System.String" />.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="value" /> does not match the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> type, or <paramref name="value" /> could not be adjusted.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.Adjust(System.TimeSpan)">
|
||
|
<param name="value">The value to validate against the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</param><summary>Validates the specified <see cref="T:System.TimeSpan" /> value against the metadata, and adjusts the value if necessary.</summary><returns>The adjusted value as an array of <see cref="T:System.TimeSpan" /> values.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentException">
|
||
|
<paramref name="value" /> does not match the <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> type, or <paramref name="value" /> could not be adjusted.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.Server.SqlMetaData.InferFromValue(System.Object,System.String)">
|
||
|
<param name="value">The object used from which the metadata is inferred.</param><param name="name">The name assigned to the returned <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</param><summary>Infers the metadata from the specified object and returns it as a <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</summary><returns>The inferred metadata as a <see cref="T:Microsoft.Data.SqlClient.Server.SqlMetaData" /> instance.</returns><remarks>To be added.</remarks><exception cref="T:System.ArgumentNullException">The <paramref name="value" /> is <see langword="null" />.</exception>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.DataClassification.ColumnSensitivity">
|
||
|
<summary>Represents the Data Classification Sensitivity Information for columns as configured in Database.</summary>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.DataClassification.ColumnSensitivity.#ctor(System.Collections.Generic.IList{Microsoft.Data.SqlClient.DataClassification.SensitivityProperty})">
|
||
|
<summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.DataClassification.ColumnSensitivity" /> class.</summary><param name="sensitivityProperties">List of sensitivity properties.</param>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.DataClassification.ColumnSensitivity.SensitivityProperties">
|
||
|
<summary>Returns the list of sensitivity properties as received from Server for this 'ColumnSensitivity' information</summary><value>List of sensitivity properties.</value>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.DataClassification.InformationType">
|
||
|
<summary>Represents the Data Classification Information Types as received from SQL Server for the active 'SqlDataReader'</summary>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.DataClassification.InformationType.#ctor(System.String,System.String)">
|
||
|
<summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.DataClassification.InformationType" /> class.</summary><param name="name">Name of Information Type.</param><param name="id">ID of Information Type.</param>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.DataClassification.InformationType.Id">
|
||
|
<summary>Gets the ID for this 'InformationType' object</summary><value>ID of Information Type.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.DataClassification.InformationType.Name">
|
||
|
<summary>Gets the name for this 'InformationType' object</summary><value>Name of Information Type.</value>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.DataClassification.Label">
|
||
|
<summary>Represents the Data Classification Labels as received from SQL Server for the active 'SqlDataReader'</summary>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.DataClassification.Label.#ctor(System.String,System.String)">
|
||
|
<summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.DataClassification.Label" /> class.</summary><param name="name">Name of label.</param><param name="id">ID of label.</param>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.DataClassification.Label.Id">
|
||
|
<summary>Gets the ID for this 'Label' object</summary><value>ID of label.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.DataClassification.Label.Name">
|
||
|
<summary>Gets the name for this 'Label' object</summary><value>Name of label.</value>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.DataClassification.SensitivityRank">
|
||
|
<summary>
|
||
|
A relative ranking of the sensitivity of a query or of a column that is part of percolumn data.
|
||
|
It is an identifier based on a predefined set of values which define sensitivity rank. Used by other services like Advanced Threat Protection to detect anomalies based on their rank.
|
||
|
</summary>
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.DataClassification.SensitivityRank.NOT_DEFINED">
|
||
|
<!-- No matching elements were found for the following include tag --><include file="../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityRank.xml" path="docs/members[@name="SensitivityRank"]/NotDefined/*" />
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.DataClassification.SensitivityRank.NONE">
|
||
|
<!-- No matching elements were found for the following include tag --><include file="../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityRank.xml" path="docs/members[@name="SensitivityRank"]/None/*" />
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.DataClassification.SensitivityRank.LOW">
|
||
|
<!-- No matching elements were found for the following include tag --><include file="../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityRank.xml" path="docs/members[@name="SensitivityRank"]/Low/*" />
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.DataClassification.SensitivityRank.MEDIUM">
|
||
|
<!-- No matching elements were found for the following include tag --><include file="../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityRank.xml" path="docs/members[@name="SensitivityRank"]/Medium/*" />
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.DataClassification.SensitivityRank.HIGH">
|
||
|
<!-- No matching elements were found for the following include tag --><include file="../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityRank.xml" path="docs/members[@name="SensitivityRank"]/High/*" />
|
||
|
</member>
|
||
|
<member name="F:Microsoft.Data.SqlClient.DataClassification.SensitivityRank.CRITICAL">
|
||
|
<!-- No matching elements were found for the following include tag --><include file="../../../../doc/snippets/Microsoft.Data.SqlClient.DataClassification/SensitivityRank.xml" path="docs/members[@name="SensitivityRank"]/Critical/*" />
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.DataClassification.SensitivityClassification">
|
||
|
<summary>Provides the functionlity to retrieve Sensitivity Classification data as received from SQL Server for the active 'SqlDataReader'</summary>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.DataClassification.SensitivityClassification.#ctor(System.Collections.Generic.IList{Microsoft.Data.SqlClient.DataClassification.Label},System.Collections.Generic.IList{Microsoft.Data.SqlClient.DataClassification.InformationType},System.Collections.Generic.IList{Microsoft.Data.SqlClient.DataClassification.ColumnSensitivity},Microsoft.Data.SqlClient.DataClassification.SensitivityRank)">
|
||
|
<summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.DataClassification.SensitivityClassification" /> class.</summary><param name="labels">List of labels.</param><param name="informationTypes">List of information types.</param><param name="columnSensitivity">List of column sensitivities.</param><param name="sensitivityRank">Relative sensitivity rank for the query associated with the active 'SqlDataReader'.</param>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.DataClassification.SensitivityClassification.ColumnSensitivities">
|
||
|
<summary>Returns the column sensitivity for this 'SensitivityClassification' Object</summary><value>List of column sensitivities.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.DataClassification.SensitivityClassification.InformationTypes">
|
||
|
<summary>Returns the information types collection for this 'SensitivityClassification' Object</summary><value>List of information types.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.DataClassification.SensitivityClassification.Labels">
|
||
|
<summary>Returns the labels collection for this 'SensitivityClassification' Object</summary><value>List of labels.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.DataClassification.SensitivityClassification.SensitivityRank">
|
||
|
<summary>Returns the relative sensitivity rank for the query associated with the active 'SqlDataReader'.</summary><value>Relative sensitivity ranking for this query.</value><remarks>
|
||
|
<format type="text/markdown">
|
||
|
<![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
A relative sensitivity ranking of the query. Available values are as below:
|
||
|
|
||
|
| Sensitivity Rank | Description |
|
||
|
| --- | --- |
|
||
|
| -1 | Not Defined (default) |
|
||
|
| 0 | None |
|
||
|
| 10 | Low |
|
||
|
| 20 | Medium |
|
||
|
| 30 | High |
|
||
|
| 40 | Critical |
|
||
|
]]>
|
||
|
</format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.DataClassification.SensitivityProperty">
|
||
|
<summary>Represents the Data Classification Sensitivity Information for columns as configured in Database.</summary>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.DataClassification.SensitivityProperty.#ctor(Microsoft.Data.SqlClient.DataClassification.Label,Microsoft.Data.SqlClient.DataClassification.InformationType,Microsoft.Data.SqlClient.DataClassification.SensitivityRank)">
|
||
|
<summary>Initializes a new instance of the <see cref="T:Microsoft.Data.SqlClient.DataClassification.SensitivityProperty" /> class.</summary><param name="label">Label for this SensitivityProperty.</param><param name="informationType">Information type for this SensitivityProperty.</param><param name="sensitivityRank">Sensitivity rank for this SensitivityProperty.</param>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.DataClassification.SensitivityProperty.InformationType">
|
||
|
<summary>Returns the information type for this 'SensitivityProperty' Object</summary><value>Information type for this SensitivityProperty.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.DataClassification.SensitivityProperty.Label">
|
||
|
<summary>Returns the label for this 'SensitivityProperty' Object</summary><value>Label for this SensitivityProperty.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.DataClassification.SensitivityProperty.SensitivityRank">
|
||
|
<summary>Returns the sensitivity rank for this 'SensitivityProperty' Object</summary><value>Sensitivity rank for this SensitivityProperty.</value><remarks>
|
||
|
<format type="text/markdown">
|
||
|
<![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
A relative sensitivity ranking of a column that is part of percolumn data. Available values are as below:
|
||
|
|
||
|
| Sensitivity Rank | Description |
|
||
|
| --- | --- |
|
||
|
| -1 | Not Defined (default) |
|
||
|
| 0 | None |
|
||
|
| 10 | Low |
|
||
|
| 20 | Medium |
|
||
|
| 30 | High |
|
||
|
| 40 | Critical |
|
||
|
]]>
|
||
|
</format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlBatch">
|
||
|
<summary /><remarks>
|
||
|
<format type="text/markdown">
|
||
|
<![CDATA[
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlConnection> and a <xref:Microsoft.Data.SqlClient.SqlBatch>, then adds multiple <xref:Microsoft.Data.SqlClient.SqlBatchCommand> objects to the batch. It then executes the batch, creating a <xref:Microsoft.Data.SqlClient.SqlDataReader>. The example reads through the results of the batch commands, writing them to the console. Finally, the example closes the <xref:Microsoft.Data.SqlClient.SqlDataReader> and then the <xref:Microsoft.Data.SqlClient.SqlConnection> as the `using` blocks fall out of scope.
|
||
|
|
||
|
[!code-csharp[SqlCommand Example#1](~/../sqlclient/doc/samples/SqlBatch_ExecuteReader.cs#1)]
|
||
|
]]>
|
||
|
</format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBatch.#ctor">
|
||
|
<summary>
|
||
|
Initializes a new <see cref="T:Microsoft.Data.SqlClient.SqlBatch" />.
|
||
|
</summary><value /><remarks>
|
||
|
<format type="text/markdown">
|
||
|
<![CDATA[
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlConnection> and a <xref:Microsoft.Data.SqlClient.SqlBatch>, then adds multiple <xref:Microsoft.Data.SqlClient.SqlBatchCommand> objects to the batch. It then executes the batch, creating a <xref:Microsoft.Data.SqlClient.SqlDataReader>. The example reads through the results of the batch commands, writing them to the console. Finally, the example closes the <xref:Microsoft.Data.SqlClient.SqlDataReader> and then the <xref:Microsoft.Data.SqlClient.SqlConnection> as the `using` blocks fall out of scope.
|
||
|
|
||
|
[!code-csharp[SqlCommand Example#1](~/../sqlclient/doc/samples/SqlBatch_ExecuteReader.cs#1)]
|
||
|
]]>
|
||
|
</format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBatch.#ctor(Microsoft.Data.SqlClient.SqlConnection,Microsoft.Data.SqlClient.SqlTransaction)">
|
||
|
<summary>Initializes a new <see cref="T:Microsoft.Data.SqlClient.SqlBatch" />.
|
||
|
</summary><param name="connection">
|
||
|
A
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
that represents the connection to an instance of SQL Server.
|
||
|
</param><param name="transaction">
|
||
|
The
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlTransaction" />
|
||
|
in which the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlCommand" />
|
||
|
executes.
|
||
|
</param><remarks>
|
||
|
<format type="text/markdown">
|
||
|
<![CDATA[
|
||
|
]]>
|
||
|
</format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBatch.Timeout">
|
||
|
<summary>Gets or sets the wait time (in seconds) before terminating the attempt to execute the batch and generating an error.</summary><value>The time in seconds to wait for the batch to execute, which is in contract with the underlaying <see cref="P:Microsoft.Data.SqlClient.SqlConnection.CommandTimeout" /></value><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
An <xref:System.ArgumentException> is generated if the assigned <xref:Microsoft.Data.SqlClient.SqlBatch.Timeout%2A> property value is less than 0.
|
||
|
|
||
|
Note to implementers: it's recommended that 0 mean no timeout.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBatch.Commands">
|
||
|
<summary>
|
||
|
The list of commands contained in the batch in a
|
||
|
<see cref="T:System.Collections.IList" /> of
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBatchCommand" /> objects.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown" />
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBatch.Connection">
|
||
|
<summary>
|
||
|
Gets or sets the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlConnection" />
|
||
|
used by this instance of the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBatch" />
|
||
|
.
|
||
|
</summary>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBatch.Transaction">
|
||
|
<summary>Gets or sets the <see cref="T:Microsoft.Data.SqlClient.SqlTransaction" /> within which the <see cref="T:Microsoft.Data.SqlClient.SqlBatch" /> commands execute.</summary>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBatch.BatchCommands">
|
||
|
<summary>
|
||
|
The list of commands contained in the batch in a <see cref="T:Microsoft.Data.SqlClient.SqlBatchCommandCollection" />.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown">
|
||
|
<![CDATA[
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlConnection> and a <xref:Microsoft.Data.SqlClient.SqlBatch>, then adds multiple <xref:Microsoft.Data.SqlClient.SqlBatchCommand> objects to the batch. It then executes the batch, creating a <xref:Microsoft.Data.SqlClient.SqlDataReader>. The example reads through the results of the batch commands, writing them to the console. Finally, the example closes the <xref:Microsoft.Data.SqlClient.SqlDataReader> and then the <xref:Microsoft.Data.SqlClient.SqlConnection> as the `using` blocks fall out of scope.
|
||
|
|
||
|
[!code-csharp[SqlCommand Example#1](~/../sqlclient/doc/samples/SqlBatch_ExecuteReader.cs#1)]
|
||
|
]]>
|
||
|
</format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBatch.DbBatchCommands">
|
||
|
<summary>Gets the collection of <see cref="T:Microsoft.Data.SqlClient.SqlBatchCommand" /> objects.</summary><value>The commands contained within the batch.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBatch.DbConnection">
|
||
|
<summary>Gets or sets the <see cref="T:System.Data.Common.DbConnection" /> used by this <see cref="T:Microsoft.Data.SqlClient.SqlBatch" />.</summary><value>The connection to the data source.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBatch.DbTransaction">
|
||
|
<summary>Gets or sets the <see cref="T:Microsoft.Data.SqlClient.SqlTransaction" /> within which this <see cref="T:Microsoft.Data.SqlClient.SqlBatch" /> object executes.</summary><value>The transaction within which a batch of a ADO.NET data provider executes. The default value is a null reference (<see langword="Nothing" /> in Visual Basic).</value>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBatch.Cancel">
|
||
|
<summary>Attempts to cancel the execution of a <see cref="T:Microsoft.Data.SqlClient.SqlBatch" />.</summary><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
If there is nothing to cancel, nothing happens. However, if there is a batch in process, and the attempt to cancel fails, no exception is generated.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBatch.CreateDbBatchCommand">
|
||
|
<summary>Creates a new instance of a <see cref="T:Microsoft.Data.SqlClient.SqlBatchCommand" /> object.</summary><returns>A <see cref="T:System.Data.Common.DbBatchCommand" /> object.</returns>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBatch.Dispose">
|
||
|
<summary>Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.</summary>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBatch.ExecuteDbDataReader(System.Data.CommandBehavior)">
|
||
|
<param name="behavior">An instance of <see cref="T:System.Data.CommandBehavior" />, specifying options for batch execution and data retrieval.</param><summary>Executes the batch against its connection, returning a <see cref="T:Microsoft.Data.SqlClient.SqlDataReader" /> which can be used to access the results.</summary><returns>A <see cref="T:System.Data.Common.DbDataReader" /> object.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
When the batch returns multiple result sets from different commands, <xref:Microsoft.Data.SqlClient.SqlDataReader.NextResult> can be used to advance the reader to the next result set.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> This method benefits from <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteReader(System.Data.CommandBehavior)>, and all the expected exceptions of that method also apply here.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:Microsoft.Data.SqlClient.SqlException">An error occurred while executing the batch.</exception><exception cref="T:System.ArgumentException">The <see cref="T:System.Data.CommandBehavior" /> value is invalid.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBatch.ExecuteDbDataReaderAsync(System.Data.CommandBehavior,System.Threading.CancellationToken)">
|
||
|
<param name="behavior">One of the enumeration values that specifies options for batch execution and data retrieval.</param><param name="cancellationToken">A token to cancel the asynchronous operation.</param><summary>This implementation invokes the <see cref="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteReaderAsync" /> method and returns a completed task. The default implementation will return a cancelled task if passed an already cancelled cancellation token.
|
||
|
|
||
|
This method accepts a cancellation token that can be used to request the operation to be cancelled early.</summary><returns>A task representing the asynchronous operation.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
For more information about asynchronous programming, see [Asynchronous Programming](/dotnet/framework/data/adonet/asynchronous-programming).
|
||
|
|
||
|
This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as <xref:System.ArgumentException>, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by <xref:System.Data.Common.DbBatch.ExecuteDbDataReader(System.Data.CommandBehavior)>.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> This method benefits from <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteReaderAsync(System.Threading.CancellationToken)>, and all the expected exceptions of that method also apply here.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:System.OperationCanceledException">The cancellation token was canceled. This exception is stored into the returned task.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBatch.ExecuteNonQuery">
|
||
|
<summary>Executes the batch against its connection object, returning the total number of rows affected across all the batch commands.</summary><returns>The total number of rows affected across all the batch commands.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
You can use <xref:Microsoft.Data.SqlClient.SqlBatch.ExecuteNonQuery%2A> to perform catalog operations (for example, querying the structure of a database or creating database objects such as tables), or to change the data in a database by executing UPDATE, INSERT, or DELETE statements.
|
||
|
|
||
|
Although <xref:Microsoft.Data.SqlClient.SqlBatch.ExecuteNonQuery%2A> does not return any rows, any output parameters or return values mapped to parameters are populated with data.
|
||
|
|
||
|
For UPDATE, INSERT, and DELETE statements, the return value is the total number of rows affected by the batch. If no UPDATE, INSERT, or DELETE statements are included in the batch, the return value is -1.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> This method benefits from <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteNonQuery>, and all the expected exceptions of that method also apply here.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBatch.ExecuteNonQueryAsync(System.Threading.CancellationToken)">
|
||
|
<param name="cancellationToken">A token to cancel the asynchronous operation.</param><summary>This is the asynchronous version of <see cref="M:Microsoft.Data.SqlClient.SqlBatch.ExecuteNonQuery" />.
|
||
|
|
||
|
The implementation invokes the <see cref="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteNonQueryAsync(System.Threading.CancellationToken)" /> method and returns a completed task. The default implementation will return a cancelled task if passed an already cancelled cancellation token.
|
||
|
|
||
|
Do not invoke other methods and properties of the <see langword="DbCommand" /> object until the returned Task is complete.</summary><returns>A task representing the asynchronous operation.</returns><remarks>
|
||
|
<format type="text/markdown"><![CDATA[
|
||
|
|
||
|
## Remarks
|
||
|
For more information about asynchronous programming, see [Asynchronous Programming](/dotnet/framework/data/adonet/asynchronous-programming).
|
||
|
|
||
|
If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as <xref:System.ArgumentException>, are still thrown synchronously.
|
||
|
|
||
|
> [!NOTE]
|
||
|
> This method benefits from <xref:Microsoft.Data.SqlClient.SqlCommand.ExecuteNonQueryAsync(System.Threading.CancellationToken)>, and all the expected exceptions of that method also apply here.
|
||
|
|
||
|
]]></format>
|
||
|
</remarks><exception cref="T:Microsoft.Data.SqlClient.SqlException">An error occurred while executing the batch.</exception><related type="Article" href="/dotnet/framework/data/adonet/ado-net-overview">ADO.NET Overview</related><exception cref="T:System.OperationCanceledException">The cancellation token was canceled. This exception is stored into the returned task.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBatch.ExecuteReader">
|
||
|
<summary>
|
||
|
Sends the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlBatch.Commands" />
|
||
|
to the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlCommand.Connection" />
|
||
|
and builds a
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlDataReader" />
|
||
|
.
|
||
|
</summary><remarks>
|
||
|
<format type="text/markdown">
|
||
|
<![CDATA[
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlConnection> and a <xref:Microsoft.Data.SqlClient.SqlBatch>, then adds multiple <xref:Microsoft.Data.SqlClient.SqlBatchCommand> objects to the batch. It then executes the batch, creating a <xref:Microsoft.Data.SqlClient.SqlDataReader>. The example reads through the results of the batch commands, writing them to the console. Finally, the example closes the <xref:Microsoft.Data.SqlClient.SqlDataReader> and then the <xref:Microsoft.Data.SqlClient.SqlConnection> as the `using` blocks fall out of scope.
|
||
|
|
||
|
[!code-csharp[SqlCommand Example#1](~/../sqlclient/doc/samples/SqlBatch_ExecuteReader.cs#1)]
|
||
|
]]>
|
||
|
</format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBatch.ExecuteReaderAsync(System.Threading.CancellationToken)">
|
||
|
<param name="cancellationToken">A token to cancel the asynchronous operation.</param><summary>
|
||
|
An asynchronous version of
|
||
|
<see cref="M:Microsoft.Data.SqlClient.SqlBatch.ExecuteReader" />
|
||
|
, which sends the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlBatch.Commands" />
|
||
|
to the
|
||
|
<see cref="P:Microsoft.Data.SqlClient.SqlBatch.Connection" />
|
||
|
and builds a
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlDataReader" />.
|
||
|
Exceptions will be reported via the returned Task object.
|
||
|
</summary><returns>A task representing the asynchronous operation.</returns><exception cref="T:Microsoft.Data.SqlClient.SqlException">An error occurred while executing the batch.</exception><exception cref="T:System.ArgumentException">The <see cref="T:System.Data.CommandBehavior" /> value is invalid.</exception><exception cref="T:System.OperationCanceledException">The cancellation token was canceled. This exception is stored into the returned task.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBatch.ExecuteScalar">
|
||
|
<summary>Executes the batch and returns the first column of the first row in the first returned result set. All other columns, rows and resultsets are ignored.</summary><returns>The first column of the first row in the first result set.</returns><exception cref="T:Microsoft.Data.SqlClient.SqlException">An error occurred while executing the batch.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBatch.ExecuteScalarAsync(System.Threading.CancellationToken)">
|
||
|
<param name="cancellationToken">A token to cancel the asynchronous operation.</param><summary>An asynchronous version of <see cref="M:Microsoft.Data.SqlClient.SqlBatch.ExecuteScalar" />, which executes the batch and returns the first column of the first row in the first returned result set. All other columns, rows and result sets are ignored.</summary><returns>The first column of the first row in the first result set.</returns><remarks>This method benefits from <see cref="M:Microsoft.Data.SqlClient.SqlCommand.ExecuteScalarAsync(System.Threading.CancellationToken)" />, and all the expected exceptions of that method also apply here. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as <see cref="T:System.ArgumentException" />, are still thrown synchronously.
|
||
|
</remarks><exception cref="T:Microsoft.Data.SqlClient.SqlException">An error occurred while executing the batch.</exception><exception cref="T:System.OperationCanceledException">The cancellation token was canceled. This exception is stored into the returned task.</exception>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBatch.Prepare">
|
||
|
<summary>Creates a prepared (or compiled) version of the batch, or of each of its commands, on the data source.</summary>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBatch.PrepareAsync(System.Threading.CancellationToken)">
|
||
|
<param name="cancellationToken">An optional token to cancel the asynchronous operation. The default value is <see cref="P:System.Threading.CancellationToken.None" />.</param><summary>Asynchronously creates a prepared (or compiled) version of the batch, or of each of its commands, on the data source.</summary><returns>A <see cref="T:System.Threading.Tasks.Task" /> representing the asynchronous operation.</returns><remarks>This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as <see cref="T:System.ArgumentException" />, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by <see cref="M:Microsoft.Data.SqlClient.SqlBatch.Prepare" />.
|
||
|
</remarks><exception cref="T:System.OperationCanceledException">The cancellation token was canceled. This exception is stored into the returned task.</exception>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlBatchCommand">
|
||
|
<summary>
|
||
|
SqlBatchCommand allows for the execution of multiple SQL commands in a SqlBatch.
|
||
|
</summary>
|
||
|
<summary>
|
||
|
SqlBatchCommand allows for the execution of multiple SQL commands in a SqlBatch.
|
||
|
</summary>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBatchCommand.#ctor">
|
||
|
<summary>Initializes a new <see cref="T:Microsoft.Data.SqlClient.SqlBatchCommand" />.</summary><remarks>
|
||
|
<format type="text/markdown">
|
||
|
<![CDATA[
|
||
|
## Examples
|
||
|
The following example creates a <xref:Microsoft.Data.SqlClient.SqlConnection> and a SqlBatch, then adds multiple <xref:Microsoft.Data.SqlClient.SqlBatchCommand> objects to the batch. It then executes the batch, creating a <xref:Microsoft.Data.SqlClient.SqlDataReader>. The example reads through the results of the batch commands, writing them to the console. Finally, the example closes the <xref:Microsoft.Data.SqlClient.SqlDataReader> and then the <xref:Microsoft.Data.SqlClient.SqlConnection> as the `using` blocks fall out of scope.
|
||
|
|
||
|
[!code-csharp[SqlCommand Example#1](~/../sqlclient/doc/samples/SqlBatch_ExecuteReader.cs#1)]
|
||
|
]]>
|
||
|
</format>
|
||
|
</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBatchCommand.#ctor(System.String,System.Data.CommandType,System.Collections.Generic.IEnumerable{Microsoft.Data.SqlClient.SqlParameter},Microsoft.Data.SqlClient.SqlCommandColumnEncryptionSetting)">
|
||
|
<summary>Initializes a new <see cref="T:Microsoft.Data.SqlClient.SqlBatchCommand" />.</summary><param name="commandText">The text of the <see cref="T:Microsoft.Data.SqlClient.SqlBatchCommand" />.</param><param name="commandType">Indicates how the <see cref="P:Microsoft.Data.SqlClient.SqlBatchCommand.CommandText" /> property is to be interpreted.</param><param name="parameters">A collection of <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> objects is used to create the <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" />.</param><param name="columnEncryptionSetting">The encryption setting. For more information, see [Always Encrypted](/sql/relational-databases/security/encryption/always-encrypted-database-engine).</param>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBatchCommand.Parameters">
|
||
|
<summary>Gets the <see cref="T:Microsoft.Data.SqlClient.SqlParameterCollection" />.</summary><value>The parameters of the Transact-SQL statement or stored procedure. The default is an empty collection.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBatchCommand.CommandText">
|
||
|
<summary>Gets or sets the text command to run against the data source.</summary><value>The text command to execute. The default value is an empty string ("").</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBatchCommand.CommandType">
|
||
|
<summary>Gets or sets how the <see cref="P:Microsoft.Data.SqlClient.SqlBatchCommand.CommandText" /> property is interpreted.</summary><value>One of the enumeration values that specifies how a command string is interpreted. The default is <see langword="Text" />.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBatchCommand.CommandBehavior">
|
||
|
<summary>
|
||
|
One of the <see cref="T:System.Data.CommandBehavior" /> values, indicating options for statement execution and data retrieval.
|
||
|
</summary>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBatchCommand.RecordsAffected">
|
||
|
<summary>
|
||
|
Gets the number of rows changed, inserted, or deleted by execution of this specific <see cref="T:Microsoft.Data.SqlClient.SqlBatchCommand" />.
|
||
|
</summary><value>
|
||
|
The number of rows changed, inserted, or deleted. -1 for SELECT statements; 0 if no rows were affected or the statement failed.
|
||
|
</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBatchCommand.DbParameterCollection">
|
||
|
<summary>Gets the collection of <see cref="T:Microsoft.Data.SqlClient.SqlParameter" /> objects.</summary><value>The parameters of the SQL statement or stored procedure.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBatchCommand.ColumnEncryptionSetting">
|
||
|
<summary>
|
||
|
Not currently implemented.
|
||
|
The encryption setting. For more information, see [Always Encrypted](/sql/relational-databases/security/encryption/always-encrypted-database-engine).
|
||
|
</summary>
|
||
|
</member>
|
||
|
<member name="T:Microsoft.Data.SqlClient.SqlBatchCommandCollection">
|
||
|
<summary>
|
||
|
A collection of instances of
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBatchCommand" />, contained within a
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBatch" />.
|
||
|
</summary>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBatchCommandCollection.Count">
|
||
|
<summary>Gets the number of elements contained in the <see cref="T:System.Collections.Generic.ICollection`1" />.</summary><value>The number of elements contained in the <see cref="T:System.Collections.Generic.ICollection`1" />.</value>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBatchCommandCollection.IsReadOnly">
|
||
|
<summary>Specifies whether the collection is read-only.</summary><value>
|
||
|
<see langword="true" /> if the collection is read-only; otherwise <see langword="false" />.</value>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBatchCommandCollection.GetEnumerator">
|
||
|
<summary>Returns the <see cref="T:Microsoft.Data.SqlClient.SqlBatchCommand" /> object at the specified index in the collection.</summary><returns>The <see cref="T:System.Data.Common.DbBatchCommand" /> object at the specified index in the collection.</returns>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBatchCommandCollection.Add(Microsoft.Data.SqlClient.SqlBatchCommand)">
|
||
|
<summary>
|
||
|
Add a
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBatchCommand" /> to the end of the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBatchCommandCollection" />.
|
||
|
</summary><value />
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBatchCommandCollection.Add(System.Data.Common.DbBatchCommand)">
|
||
|
<param name="item">
|
||
|
The object to add to the <see cref="T:System.Collections.Generic.ICollection`1" />.
|
||
|
</param><summary>
|
||
|
Adds the specified <see cref="T:System.Data.Common.DbBatchCommand" /> object to the <see cref="T:System.Collections.Generic.ICollection`1" />.
|
||
|
</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBatchCommandCollection.Clear">
|
||
|
<summary>Removes all <see cref="T:Microsoft.Data.SqlClient.SqlBatchCommand" /> values from the <see cref="T:Microsoft.Data.SqlClient.SqlBatchCommandCollection" />.</summary>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBatchCommandCollection.Contains(Microsoft.Data.SqlClient.SqlBatchCommand)">
|
||
|
<summary>
|
||
|
Determines whether a
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBatchCommand" /> is in the
|
||
|
<see cref="T:Microsoft.Data.SqlClient.SqlBatchCommandCollection" />.
|
||
|
</summary><value />
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBatchCommandCollection.Contains(System.Data.Common.DbBatchCommand)">
|
||
|
<param name="item">
|
||
|
The object to locate in the <see cref="T:System.Collections.Generic.ICollection`1" />.
|
||
|
</param><summary>
|
||
|
Indicates whether a <see cref="T:System.Data.Common.DbBatchCommand" /> is contained in the collection.
|
||
|
</summary><returns>
|
||
|
<see langword="true" /> if the <see cref="T:System.Data.Common.DbBatchCommand" /> is in the collection; otherwise <see langword="false" />.
|
||
|
</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBatchCommandCollection.CopyTo(Microsoft.Data.SqlClient.SqlBatchCommand[],System.Int32)">
|
||
|
<summary>
|
||
|
Copies the entire <see cref="T:Microsoft.Data.SqlClient.SqlBatchCommandCollection" /> to a one dimensional array, starting at the target index of the target array.
|
||
|
</summary><value />
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBatchCommandCollection.CopyTo(System.Data.Common.DbBatchCommand[],System.Int32)">
|
||
|
<param name="array">
|
||
|
The one-dimensional <see cref="T:System.Array" /> that is the destination of the elements copied from <see cref="T:System.Collections.Generic.ICollection`1" />. The <see cref="T:System.Array" /> must have zero-based indexing.
|
||
|
</param><param name="arrayIndex">
|
||
|
The zero-based index in <paramref name="array" /> at which copying begins.
|
||
|
</param><summary>
|
||
|
Copies the elements of the <see cref="T:System.Collections.Generic.ICollection`1" /> to an <see cref="T:System.Array" />, starting at a particular <see cref="T:System.Array" /> index.
|
||
|
</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBatchCommandCollection.IndexOf(Microsoft.Data.SqlClient.SqlBatchCommand)">
|
||
|
<summary>
|
||
|
Searches for the specified <see cref="T:Microsoft.Data.SqlClient.SqlBatchCommand" /> within the <see cref="T:Microsoft.Data.SqlClient.SqlBatchCommandCollection" /> and returns the zero-based index of the first occurence within the entire <see cref="T:Microsoft.Data.SqlClient.SqlBatchCommandCollection" />.
|
||
|
</summary><returns>
|
||
|
Returns the zero-based index of the first occurence within the entire <see cref="T:Microsoft.Data.SqlClient.SqlBatchCommandCollection" />.
|
||
|
</returns>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBatchCommandCollection.IndexOf(System.Data.Common.DbBatchCommand)">
|
||
|
<param name="item">
|
||
|
The object to locate in the <see cref="T:System.Collections.Generic.IList`1" />.
|
||
|
</param><summary>
|
||
|
Returns the index of the specified <see cref="T:System.Data.Common.DbBatchCommand" /> object.
|
||
|
</summary><returns>
|
||
|
The index of the specified <see cref="T:System.Data.Common.DbBatchCommand" /> object.
|
||
|
</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBatchCommandCollection.Insert(System.Int32,Microsoft.Data.SqlClient.SqlBatchCommand)">
|
||
|
<summary>
|
||
|
Inserts an item into the <see cref="T:Microsoft.Data.SqlClient.SqlBatchCommandCollection" /> at the specified index.
|
||
|
</summary><exception cref="T:System.ArgumentOutOfRangeException" />
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBatchCommandCollection.Insert(System.Int32,System.Data.Common.DbBatchCommand)">
|
||
|
<param name="index">
|
||
|
The index at which to insert the <see cref="T:System.Data.Common.DbBatchCommand" /> object.
|
||
|
</param><param name="item">
|
||
|
The object to insert into the <see cref="T:System.Collections.Generic.IList`1" />.
|
||
|
</param><summary>
|
||
|
Inserts the specified index of the <see cref="T:System.Data.Common.DbBatchCommand" /> object with the specified name into the collection at the specified index.
|
||
|
</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBatchCommandCollection.Remove(Microsoft.Data.SqlClient.SqlBatchCommand)">
|
||
|
<summary>
|
||
|
Removes the first occurence of a specific <see cref="T:Microsoft.Data.SqlClient.SqlBatchCommand" /> object from the collection.
|
||
|
</summary><returns>
|
||
|
Returns <see langword="true" /> if an item is successfully removed. Returns false if an item could not be removed or no item was not found.
|
||
|
</returns>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBatchCommandCollection.Remove(System.Data.Common.DbBatchCommand)">
|
||
|
<param name="item">
|
||
|
The object to remove from the <see cref="T:System.Collections.Generic.ICollection`1" />.
|
||
|
</param><summary>
|
||
|
Removes the specified <see cref="T:Microsoft.Data.SqlClient.SqlBatchCommand" /> object from the collection.
|
||
|
</summary><returns>
|
||
|
<see langword="true" /> if <paramref name="item" /> was successfully removed; otherwise, <see langword="false" />. This method also returns <see langword="false" /> if <paramref name="item" /> was not found in the <see cref="T:System.Collections.Generic.ICollection`1" />.
|
||
|
</returns><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBatchCommandCollection.RemoveAt(System.Int32)">
|
||
|
<param name="index">The index where the <see cref="T:Microsoft.Data.SqlClient.SqlBatchCommand" /> object is located.</param><summary>Removes the <see cref="T:Microsoft.Data.SqlClient.SqlBatchCommand" /> object at the specified index from the collection.</summary>
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBatchCommandCollection.System#Collections#Generic#IList{Microsoft#Data#SqlClient#SqlBatchCommand}#Item(System.Int32)">
|
||
|
<summary>Gets or Sets the element at the specified index.</summary><returns>The element at the specified index.</returns><exception cref="T:System.ArgumentOutOfRangeException" />
|
||
|
</member>
|
||
|
<member name="P:Microsoft.Data.SqlClient.SqlBatchCommandCollection.Item(System.Int32)">
|
||
|
<summary>Gets or Sets the element at the specified index.</summary><returns>The element at the specified index.</returns><exception cref="T:System.ArgumentOutOfRangeException" />
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBatchCommandCollection.GetBatchCommand(System.Int32)">
|
||
|
<param name="index">
|
||
|
The index where the <see cref="T:Microsoft.Data.SqlClient.SqlBatchCommand" /> object is located.
|
||
|
</param><summary>
|
||
|
Returns the <see cref="T:Microsoft.Data.SqlClient.SqlBatchCommand" /> object at the specified index in the list.
|
||
|
</summary><returns>
|
||
|
The <see cref="T:Microsoft.Data.SqlClient.SqlBatchCommand" /> object at the specified index in the list.
|
||
|
</returns>
|
||
|
</member>
|
||
|
<member name="M:Microsoft.Data.SqlClient.SqlBatchCommandCollection.SetBatchCommand(System.Int32,System.Data.Common.DbBatchCommand)">
|
||
|
<param name="index">
|
||
|
The index where the <see cref="T:Microsoft.Data.SqlClient.SqlBatchCommand" /> object should be located.
|
||
|
</param><param name="batchCommand">To be added.</param><summary>
|
||
|
Sets the <see cref="T:Microsoft.Data.SqlClient.SqlBatchCommand" /> object at the specified index to a new value.
|
||
|
</summary><remarks>To be added.</remarks>
|
||
|
</member>
|
||
|
</members>
|
||
|
</doc>
|