共用方式為


DataSourceAttribute Class

Definition

Specifies connection string, table name and row access method for data driven testing.

public ref class DataSourceAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=false)]
public sealed class DataSourceAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Method, AllowMultiple=false)>]
type DataSourceAttribute = class
    inherit Attribute
Public NotInheritable Class DataSourceAttribute
Inherits Attribute
Inheritance
DataSourceAttribute
Attributes

Examples

[DataSource("Provider=SQLOLEDB.1;Data Source=source;Integrated Security=SSPI;Initial Catalog=EqtCoverage;Persist Security Info=False", "MyTable")] [DataSource("dataSourceNameFromConfigFile")]

Constructors

DataSourceAttribute(String, String, String, DataAccessMethod)

Initializes a new instance of the DataSourceAttribute class. This instance will be initialized with a data provider, connection string, data table and data access method to access the data source.

DataSourceAttribute(String, String)

Initializes a new instance of the DataSourceAttribute class.This instance will be initialized with a connection string and table name. Specify connection string and data table to access OLEDB data source.

DataSourceAttribute(String)

Initializes a new instance of the DataSourceAttribute class. This instance will be initialized with a data provider and connection string associated with the setting name.

Fields

DefaultDataAccessMethod

The default data access method.

DefaultProviderName

The default provider name for DataSource.

Properties

ConnectionString

Gets a value representing the connection string for the data source.

DataAccessMethod

Gets the method used to access the data source.

DataSourceSettingName

Gets the name of a data source found in the <microsoft.visualstudio.qualitytools> section in the app.config file.

ProviderInvariantName

Gets a value representing the data provider of the data source.

TableName

Gets a value indicating the table name providing data.

Applies to