ServerConnection 클래스
The ServerConnection object represents a connection to a server.
네임스페이스: Microsoft.SqlServer.Management.Common
어셈블리: Microsoft.SqlServer.ConnectionInfo.dll의 Microsoft.SqlServer.ConnectionInfo
구문
‘선언
Public NotInheritable Class ServerConnection _
Inherits ConnectionManager _
Implements ISfcConnection
‘사용 방법
Dim instance As ServerConnection
public sealed class ServerConnection : ConnectionManager,
ISfcConnection
public ref class ServerConnection sealed : public ConnectionManager,
ISfcConnection
[<SealedAttribute>]
type ServerConnection =
class
inherit ConnectionManager
interface ISfcConnection
end
public final class ServerConnection extends ConnectionManager implements ISfcConnection
주의
The ServerConnection class is served by the Server class and replication classes such as the ReplicationServer class.
Typically, you don't have to declare an instance of the ServerConnection object because it is created automatically with the Server object. Declare a ServerConnection object variable if you want to store the connection settings for re-use. The ConnectionContext property of the Server object points to a ServerConnection object. The ServerConnection object contains properties that relate to the connection between the Server object and the instance of SQL Server. You can use it to view or modify certain aspects of the connection, such as the process ID, processing transactions, the authentication mode, execution mode, and even to run Transact-SQL commands directly.
By using the ServerConnection object, you can do the following:
Run Transact-SQL statements directly over the connection to the instance of SQL Server.
Change the connection settings, such as the authentication method.
Begin, commit and roll back transactions.
Capture the Transact-SQL statements generated by the SMO application.
예제
For another example of this method with the Database object, see [M:Microsoft.SqlServer.Management.Smo.Database.ExecuteNonQuery(System.String].
'Declare a ServerConnection object variable to specify SQL authentication, login and password.
Dim conn As New ServerConnection
conn.LoginSecure = False
conn.Login = vlogin
conn.Password = vpassword
'Connect to the local, default instance of SQL Server.
Dim srv As Server
srv = New Server(conn)
'The actual connection is made when a property is retrieved.
Console.WriteLine(srv.Information.Version)
'The connection is automatically disconnected when the Server variable goes out of scope.
상속 계층 구조
System. . :: . .Object
Microsoft.SqlServer.Management.Common. . :: . .ConnectionSettings
Microsoft.SqlServer.Management.Common. . :: . .ConnectionManager
Microsoft.SqlServer.Management.Common..::..ServerConnection
스레드로부터의 안전성
이 형식의 모든 공용 static(Visual Basic에서는 Shared) 멤버는 스레드로부터 안전합니다. 인스턴스 멤버는 스레드로부터의 안전성이 보장되지 않습니다.