获取或设置要连接到的 Oracle 数据源的名称。Gets or sets the name of the Oracle data source to connect to.
public:
property System::String ^ DataSource { System::String ^ get(); void set(System::String ^ value); };
public string DataSource { get; set; }
member this.DataSource : string with get, set
Public Property DataSource As String
属性值
为 DataSource 属性的值,或者,如果未提供任何值,则为 Empty。The value of the DataSource property, or Empty if none has been supplied.
示例
下面的示例演示 OracleConnectionStringBuilder 类将 "数据源" 连接字符串密钥的同义词转换为众所周知的键。The following example demonstrates that the OracleConnectionStringBuilder class converts synonyms for the "Data Source" connection string key into the well-known key.
// You may need to set a reference to the System.Data.OracleClient
// assembly before you can run this sample.
using System.Data.OracleClient;
class Program
{
static void Main()
{
OracleConnectionStringBuilder builder =
new OracleConnectionStringBuilder(
"Server=OracleDemo;Integrated Security=True");
// Display the connection string, which should now
// contains the "Data Source" key, as opposed to the
// supplied "Server".
Console.WriteLine(builder.ConnectionString);
// Retrieve the DataSource property.
Console.WriteLine("DataSource = " + builder.DataSource);
Console.WriteLine("Press any key to continue.");
Console.ReadLine();
}
}' You may need to set a reference to the System.Data.OracleClient
' assembly before running this example.
Imports System.Data.OracleClient
Module Module1
Sub Main()
Dim builder As _
New OracleConnectionStringBuilder( _
"Server=OracleDemo;Integrated Security=True")
' Display the connection string, which should now
' contains the "Data Source" key, as opposed to the
' supplied "Server".
Console.WriteLine(builder.ConnectionString)
' Retrieve the DataSource property.
Console.WriteLine("DataSource = " & builder.DataSource)
Console.WriteLine("Press any key to continue.")
Console.ReadLine()
End Sub
End Module
注解
此属性对应于连接字符串中的 "数据源" 和 "服务器" 键。This property corresponds to the "Data Source" and "Server" keys within the connection string. 无论在提供的连接字符串中提供了哪些值,由创建的连接字符串 OracleConnectionStringBuilder 将使用众所周知的 "数据源" 键。Regardless of which of these values has been supplied within the supplied connection string, the connection string created by the OracleConnectionStringBuilder will use the well-known "Data Source" key. 如果在您尝试设置此属性时传入的值为 null,则将重置 DataSource 属性。If the value passed in is null when you try to set the property, the DataSource property is reset. 如果尚未设置值,而开发人员尝试检索属性,则返回值为 Empty 。If the value has not been set and the developer tries to retrieve the property, the return value is Empty.
适用于