Server.ConnectionContext Server.ConnectionContext Server.ConnectionContext Property


Gets the current server connection details for the instance of SQL Server.

 property Microsoft::SqlServer::Management::Common::ServerConnection ^ ConnectionContext { Microsoft::SqlServer::Management::Common::ServerConnection ^ get(); };
public Microsoft.SqlServer.Management.Common.ServerConnection ConnectionContext { get; }
Public ReadOnly Property ConnectionContext As ServerConnection
Property Value
Microsoft.SqlServer.Management.Common.ServerConnection Microsoft.SqlServer.Management.Common.ServerConnection Microsoft.SqlServer.Management.Common.ServerConnection

A Microsoft.SqlServer.Management.Common.ServerConnection object that specifies the details of the current connection to the instance of SQL Server.




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);  


$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)  


This property can be used to change connection settings, such as the name of the instance of SQL Server or the authentication type. The ConnectionContext property is represented by the <xref:Microsoft.SqlServer.Management.Common.ServerConnection> class. When connecting to the local instance of SQL Server by using Windows Authentication, the default values are used. You do not have to set any properties.

Applies to