Share via


Server.ConnectionContext プロパティ

SQL Server のインスタンスの現在のサーバー接続の詳細を取得します。

名前空間:  Microsoft.SqlServer.Management.Smo
アセンブリ:  Microsoft.SqlServer.Smo (Microsoft.SqlServer.Smo.dll)

構文

'宣言
Public ReadOnly Property ConnectionContext As ServerConnection 
    Get
'使用
Dim instance As Server 
Dim value As ServerConnection 

value = instance.ConnectionContext
public ServerConnection ConnectionContext { get; }
public:
virtual property ServerConnection^ ConnectionContext {
    ServerConnection^ get () sealed;
}
abstract ConnectionContext : ServerConnection 
override ConnectionContext : ServerConnection
final function get ConnectionContext () : ServerConnection

プロパティ値

型: Microsoft.SqlServer.Management.Common.ServerConnection
SQL Server のインスタンスへの現在の接続の詳細を示す ServerConnection オブジェクトです。

実装

IAlienRoot.ConnectionContext

説明

このプロパティは、SQL Server のインスタンスの名前や認証の種類などの接続設定を変更するために使用できます。 ConnectionContext プロパティは、ServerConnection クラスによって表されます。 Windows 認証を使用して SQL Server のローカル インスタンスに接続する場合は、既定値が使用されます。 プロパティを設定する必要はありません。

使用例

C#

Server srv = new Server("(local)");
ServerConnection conContext = new ServerConnection();
conContext = srv.ConnectionContext;
conContext.LoginSecure = false;
conContext.Login = vlogin;
conContext.Password = vpassword;
Server srv2 = new Server(conContext);

PowerShell

$srv = new-object Microsoft.SqlServer.Management.Smo.Server("(local)")
$conContext = $srv.ConnectionContext
$conContext.LoginSecure = $FALSE
$conContext.Login = vlogin
$conContext.Password = vpassword
$srv2 = new-object Microsoft.SqlServer.Management.Smo.Server($conContext)

関連項目

参照

Server クラス

Microsoft.SqlServer.Management.Smo 名前空間

その他の技術情報

SQL Server のインスタンスへの接続

SQL Server のインスタンスからの切断

サーバーの管理