ConnectionManager Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
connection settings and creation
public abstract class ConnectionManager : Microsoft.SqlServer.Management.Common.ConnectionSettings
type ConnectionManager = class
inherit ConnectionSettings
Public MustInherit Class ConnectionManager
Inherits ConnectionSettings
- Inheritance
- Derived
Fields
NoConnectionTimeout |
Infinite wait (Inherited from ConnectionSettings) |
Properties
AccessToken | (Inherited from ConnectionSettings) |
ApplicationIntent |
The application intent of the connection Valid values are ReadWrite and ReadOnly (Inherited from ConnectionSettings) |
ApplicationName |
The name of the application. 'SQL Management' if no application name has been provided. Exceptions: ConnectionCannotBeChangedException InvalidPropertyValueException (Inherited from ConnectionSettings) |
Authentication |
The authentication type of the connection (Inherited from ConnectionSettings) |
AutoDisconnectMode | |
CapturedSql | |
ConnectAsUser |
If set to true, the connection will be made with the credentials of the specified user. This will assume impersonation, however the LoginSecure flags and Login and Password fields will not be affected. ConnectionCannotBeChangedException (Inherited from ConnectionSettings) |
ConnectAsUserName |
Specifies the NT user that is used when creating an impersonated connection. Exceptions: ConnectionCannotBeChangedException InvalidPropertyValueException PropertyNotSetException (Inherited from ConnectionSettings) |
ConnectAsUserPassword |
Specifies password of the NT user that is used when creating an impersonated connection. Exceptions: ConnectionCannotBeChangedException InvalidPropertyValueException PropertyNotSetException (Inherited from ConnectionSettings) |
ConnectionProtocol |
Connection protocol. |
ConnectionString |
The property will return either the user specified connection string or it will return the computed connection string based on object settings. If explicitly set, All properties in the ServerConnection object will be populated to reflect the passed in connection string. Exceptions: ConnectionCannotBeChangedException InvalidPropertyValueException (Inherited from ConnectionSettings) |
ConnectTimeout |
The length of time (in seconds) to wait for a connection to the server before terminating the attempt and throwing an exception. Default is 30 seconds (same as Shiloh). Exceptions: ConnectionCannotBeChangedException InvalidPropertyValueException (Inherited from ConnectionSettings) |
CurrentDatabase |
Returns the current database context. |
DatabaseEngineEdition |
The edition of the Database Engine |
DatabaseEngineType |
Returns the database engine type of SQL Server. Exceptions: ConnectionFailureException |
DatabaseName |
TBD (Inherited from ConnectionSettings) |
EncryptConnection |
whether "encrypt=true" is specified in the connection string (Inherited from ConnectionSettings) |
HostPlatform |
The host platform of the server (Linux/Windows/etc) |
InUse |
Returns true if the object has been connected with the server at least once. If true, property changes are not allowed any more and ConnectionCannotBeChangedException will be thrown when a property has been changed. |
IsContainedAuthentication |
Returns true if the database engine authenticates using contained authentication. Exceptions: ConnectionFailureException |
IsForceDisconnected |
Indicates that the connection has been forcefully disconnected |
IsOpen |
Returns true if the SqlConnection object is connected with the server. This can only return true for non pooled connections as pooled connections are always closed directly after an operation. |
LockTimeout |
LockTimeout is the Lock timeout in seconds. Default -1 is for indefinite. InvalidPropertyValueException is thrown for all other negative numbers. Positive LockTimeout will be multiplied by 1000 and then used for "SET LOCK_TIMEOUT" setting. |
Login |
The SQL Server Login name that is used to connect to the server. Exceptions: ConnectionCannotBeChangedException InvalidPropertyValueException PropertyNotSetException (Inherited from ConnectionSettings) |
LoginSecure |
If set to true, Windows integrate security is used and Login and Password are ignored. If not set, Sql Server Authentication is used. Exceptions: ConnectionCannotBeChangedException (Inherited from ConnectionSettings) |
MaxPoolSize |
The maximum number of connections allowed in the pool. Exceptions: ConnectionCannotBeChangedException InvalidPropertyValueException (Inherited from ConnectionSettings) |
MinPoolSize |
The minimum number of connections maintained in the pool. Exceptions: ConnectionCannotBeChangedException InvalidPropertyValueException (Inherited from ConnectionSettings) |
MultipleActiveResultSets |
Enable MARS from the connection. Default is false. (Inherited from ConnectionSettings) |
NetworkProtocol |
Identifies the client network protocol that is used to connect to SQL Server. If you do not specify a network and you use a local server, shared memory is used. If you do not specify a network and you use a remote server, the one of the configured client protocols is used. Exceptions: ConnectionCannotBeChangedException InvalidPropertyValueException (Inherited from ConnectionSettings) |
NonPooledConnection |
By default, all connections to SQL Server are taken from an ADO.NET connection pool.If set to true, this allows users to create a non-pooled connection (will not be reused when closed). Exceptions: ConnectionCannotBeChangedException (Inherited from ConnectionSettings) |
PacketSize |
Size in bytes of the network packets used to communicate with an instance of SQL Server. Default is 8192. Exceptions: ConnectionCannotBeChangedException InvalidPropertyValueException (Inherited from ConnectionSettings) |
Password |
The password that is used with Login to connect to the server. Exceptions: ConnectionCannotBeChangedException InvalidPropertyValueException PropertyNotSetException (Inherited from ConnectionSettings) |
PooledConnectionLifetime |
When a connection is returned to the pool, its creation time is compared with the current time, and the connection is destroyed if that time span (in seconds) exceeds the value specified by connection lifetime. Exceptions: ConnectionCannotBeChangedException InvalidPropertyValueException (Inherited from ConnectionSettings) |
ProductVersion |
Gets the ProductVersion server property of this connection |
ResetConnectionString |
Tells us whether ConnectionString needs to be reset in SqlConnectionObject property of ConnectionManager or not. (Inherited from ConnectionSettings) |
SecureConnectionString |
The property will return a SecureString version of either the user specified connection string or it will return the computed connection string based on object settings. If explicitly set, All properties in the ServerConnection object will be populated to reflect the passed in connection string. Exceptions: ConnectionCannotBeChangedException (Inherited from ConnectionSettings) |
SecurePassword |
The password that is used with Login to connect to the server. Exceptions: ConnectionCannotBeChangedException InvalidPropertyValueException PropertyNotSetException (Inherited from ConnectionSettings) |
ServerInstance |
The name of the SQL Server the object will connect to. If not set, the local server is implied. Exceptions: ConnectionCannotBeChangedException InvalidPropertyValueException (Inherited from ConnectionSettings) |
ServerVersion |
Returns the major version number of SQL Server. I.e. 8 for SQL Server 2000. Exceptions: ConnectionFailureException |
SqlConnectionObject |
Returns a reference to the SqlConnection object used by the ConnectionContext object. This should always return the valid sqlConnection object with the latest valid ConnectionString set. Exceptions: PropertyNotAvailableException |
TrustServerCertificate |
Indicate whether the client trusts the server certificate (Inherited from ConnectionSettings) |
WorkstationId |
The name of the workstation connecting to SQL Server. Exceptions: ConnectionCannotBeChangedException InvalidPropertyValueException (Inherited from ConnectionSettings) |
Methods
CheckServerVersion(ServerVersion) |
Check if we are connecting to a supported server version. block off <= 7.0 in ServerConnection. |
Connect() |
Creates the actual connection to SQL Server. Ignored if already connected. It is optional to call this method, as the connection will be opened when required. Exceptions: ConnectionFailureException |
Disconnect() |
Closes the connection with SQL Server. Ignored if already disconnected. Exceptions: ConnectionFailureException |
ExecuteTSql(ConnectionManager+ExecuteTSqlAction, Object, DataSet, Boolean) |
Executes T-SQL using the appropriate methods depending on the action information passed as the parameter. |
ForceDisconnected() |
Enforces a disconnect and ensures that connection cannot be re-opened again |
ThrowIfPropertyNotSet(String, String) | (Inherited from ConnectionSettings) |
ThrowIfPropertyNotSet(String, String, Boolean) | (Inherited from ConnectionSettings) |
ToString() | (Inherited from ConnectionSettings) |
Events
InfoMessage |
Occurs when SQL Server returns a warning or informational message. Uses SqlClient.SqlInfoMessageEventHandler. |
RemoteLoginFailed |
Called when the server needs to connect to remote servers and the login fails |
ServerMessage |
Occurs when SQL Server returns a warning or informational message. Uses SqlClient.SqlInfoMessageEventHandler. |
StateChange |
Occurs when the state of the connection changes. Uses System.Data.StateChangeEventHandler. |
StatementExecuted |