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會將 「Data Source」 連接字串 索引鍵的同義字轉換成已知的索引鍵。
// 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。