OracleConnectionStringBuilder.DataSource 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置要连接到的 Oracle 数据源的名称。
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。
示例
以下示例演示 OracleConnectionStringBuilder 类将“数据源”的同义词连接字符串键转换为已知键。
// 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
注解
此属性对应于连接字符串中的“数据源”和“服务器”键。 无论在提供的连接字符串中提供了这些值中的哪一个,由 OracleConnectionStringBuilder 创建的连接字符串都将使用已知的“数据源”键。 如果在您尝试设置此属性时传入的值为 null,则将重置 DataSource 属性。 如果尚未设置该值,并且开发人员尝试检索属性,则返回值为 Empty。