DbConnection.DataSource 属性

定义

在派生类中重写时,获取要连接的数据库服务器的名称。When overridden in a derived class, gets the name of the database server to which to connect.

public:
 abstract property System::String ^ DataSource { System::String ^ get(); };
public abstract string DataSource { get; }
member this.DataSource : string
Public MustOverride ReadOnly Property DataSource As String

属性值

String

要连接的数据库服务器的名称。The name of the database server to which to connect. 默认值为一个空字符串。The default value is an empty string.

注解

如果与数据库的连接已关闭,则将 DataSource 返回关键字中包含的任何内容 ConnectionString DataSourceIf the connection to the database is closed, the DataSource returns whatever is contained in the ConnectionString for the DataSource keyword. 如果连接处于打开状态,并且 ConnectionString 数据源关键字的值以 "|datadirectory|" 开头,则属性将返回中包含的所有内容( ConnectionString 仅适用于 DataSource 关键字)。If the connection is open and the ConnectionString data source keyword's value starts with "|datadirectory|", the property returns whatever is contained in the ConnectionString for the DataSource keyword only. 如果与数据库的连接已打开,则属性返回本机提供程序为返回的内容, DBPROP_INIT_DATASOURCE 如果为空,则返回本机提供程序的 DBPROP_DATASOURCENAMEIf the connection to the database is open, the property returns what the native provider returns for the DBPROP_INIT_DATASOURCE, and if that is empty, the native provider's DBPROP_DATASOURCENAME is returned.

适用于