SqlConnectionStringBuilder.DataSource SqlConnectionStringBuilder.DataSource SqlConnectionStringBuilder.DataSource SqlConnectionStringBuilder.DataSource Property


接続する先の SQL Server インスタンスの名前またはネットワーク アドレスを取得または設定します。Gets or sets the name or network address of the instance of SQL Server to connect to.

 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 プロパティの値。値が指定されていない場合は String.EmptyThe value of the DataSource property, or String.Empty if none has been supplied.


値を null に設定するには、Value を使用します。To set the value to null, use Value.

次の例は、SqlConnectionStringBuilder クラスによって、"Data Source" 接続文字列キーに対応するシノニムが既知のキーに変換されることを示しています。The following example demonstrates that the SqlConnectionStringBuilder class converts synonyms for the "Data Source" connection string key into the well-known key:

using System.Data.SqlClient;

class Program
    static void Main()
        SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(
            "Network Address=(local);Integrated Security=SSPI;" +
            "Initial Catalog=AdventureWorks");

        // Display the connection string, which should now 
        // contain the "Data Source" key, as opposed to the 
        // supplied "Network Address".

        // Retrieve the DataSource property.
        Console.WriteLine("DataSource = " + builder.DataSource);

        Console.WriteLine("Press any key to continue.");
Imports System.Data.SqlClient

Module Module1

    Sub Main()
        Dim builder As _
         New SqlConnectionStringBuilder( _
         "Network Address=(local);Integrated Security=SSPI;" & _
         "Initial Catalog=AdventureWorks")

        ' Display the connection string, which should now 
        ' contain the "Data Source" key, as opposed to the 
        ' supplied "Network Address".

        ' Retrieve the DataSource property:
        Console.WriteLine("DataSource = " & builder.DataSource)

        Console.WriteLine("Press any key to continue.")
    End Sub
End Module


このプロパティは、接続文字列内の "Data Source" キー、"server" キー、"address" キー、"addr" キー、および "network address" キーに対応しています。This property corresponds to the "Data Source", "server", "address", "addr", and "network address" keys within the connection string. 上記のどの値が指定された接続文字列内で指定されてに関係なく、によって作成された接続文字列、SqlConnectionStringBuilderよく知られている"Data Source"キーが使用されます。Regardless of which of these values has been supplied within the supplied connection string, the connection string created by the SqlConnectionStringBuilder will use the well-known "Data Source" key.