SqlConnection.GetSchemaAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| Name | Description |
|---|---|
| GetSchemaAsync(CancellationToken) |
An asynchronous version of GetSchema(), which returns schema information for the data source of this SqlConnection. For more information about schemas, see SQL Server Schema Collections. |
| GetSchemaAsync(String, CancellationToken) |
An asynchronous version of GetSchema(String), which returns schema information for the data source of this SqlConnection using the specified string for the schema name. |
| GetSchemaAsync(String, String[], CancellationToken) |
An asynchronous version of GetSchema(String, String[]), which returns schema information for the data source of this SqlConnection using the specified string for the schema name and the specified string array for the restriction values. |
GetSchemaAsync(CancellationToken)
An asynchronous version of GetSchema(), which returns schema information for the data source of this SqlConnection. For more information about schemas, see SQL Server Schema Collections.
public System.Threading.Tasks.Task<System.Data.DataTable> GetSchemaAsync(System.Threading.CancellationToken cancellationToken = default);
public override System.Threading.Tasks.Task<System.Data.DataTable> GetSchemaAsync(System.Threading.CancellationToken cancellationToken = default);
member this.GetSchemaAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Data.DataTable>
override this.GetSchemaAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Data.DataTable>
Public Function GetSchemaAsync (Optional cancellationToken As CancellationToken = Nothing) As Task(Of DataTable)
Public Overrides Function GetSchemaAsync (Optional cancellationToken As CancellationToken = Nothing) As Task(Of DataTable)
Parameters
- cancellationToken
- CancellationToken
The cancellation token.
Returns
A task representing the asynchronous operation.
Remarks
For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see Asynchronous Programming.
Applies to
GetSchemaAsync(String, CancellationToken)
An asynchronous version of GetSchema(String), which returns schema information for the data source of this SqlConnection using the specified string for the schema name.
public System.Threading.Tasks.Task<System.Data.DataTable> GetSchemaAsync(string collectionName, System.Threading.CancellationToken cancellationToken = default);
public override System.Threading.Tasks.Task<System.Data.DataTable> GetSchemaAsync(string collectionName, System.Threading.CancellationToken cancellationToken = default);
member this.GetSchemaAsync : string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Data.DataTable>
override this.GetSchemaAsync : string * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Data.DataTable>
Public Function GetSchemaAsync (collectionName As String, Optional cancellationToken As CancellationToken = Nothing) As Task(Of DataTable)
Public Overrides Function GetSchemaAsync (collectionName As String, Optional cancellationToken As CancellationToken = Nothing) As Task(Of DataTable)
Parameters
- collectionName
- String
Specifies the name of the schema to return.
- cancellationToken
- CancellationToken
The cancellation token.
Returns
A task representing the asynchronous operation.
Exceptions
collectionName is specified as null.
Remarks
For more information about asynchronous programming in the .NET Framework Data Provider for SQL Server, see Asynchronous Programming.
Applies to
GetSchemaAsync(String, String[], CancellationToken)
An asynchronous version of GetSchema(String, String[]), which returns schema information for the data source of this SqlConnection using the specified string for the schema name and the specified string array for the restriction values.
public System.Threading.Tasks.Task<System.Data.DataTable> GetSchemaAsync(string collectionName, string[] restrictionValues, System.Threading.CancellationToken cancellationToken = default);
public override System.Threading.Tasks.Task<System.Data.DataTable> GetSchemaAsync(string collectionName, string[] restrictionValues, System.Threading.CancellationToken cancellationToken = default);
member this.GetSchemaAsync : string * string[] * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Data.DataTable>
override this.GetSchemaAsync : string * string[] * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Data.DataTable>
Public Function GetSchemaAsync (collectionName As String, restrictionValues As String(), Optional cancellationToken As CancellationToken = Nothing) As Task(Of DataTable)
Public Overrides Function GetSchemaAsync (collectionName As String, restrictionValues As String(), Optional cancellationToken As CancellationToken = Nothing) As Task(Of DataTable)
Parameters
- collectionName
- String
Specifies the name of the schema to return.
- restrictionValues
- String[]
A set of restriction values for the requested schema.
- cancellationToken
- CancellationToken
The cancellation token.
Returns
A task representing the asynchronous operation.
Exceptions
collectionName is specified as null.
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.