Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Collapse the table of content
Expand the table of content
Expand Minimize

Server::ConnectionContext Property


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

Namespace:   Microsoft.SqlServer.Management.Smo
Assembly:  Microsoft.SqlServer.Smo (in Microsoft.SqlServer.Smo.dll)

property ServerConnection^ ConnectionContext {
	virtual ServerConnection^ get() sealed;

Property Value

Type: Microsoft.SqlServer.Management.Common::ServerConnection^

A ServerConnection object that specifies the details of the current connection to the instance of SQL Server.

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 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.


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)
Return to top
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft