Udostępnij za pośrednictwem


Konstruktor Server (String)

Inicjuje nowe wystąpienie Server klasy z określonej nazwy.

Przestrzeń nazw:  Microsoft.SqlServer.Management.Smo
Zestaw:  Microsoft.SqlServer.Smo (w Microsoft.SqlServer.Smo.dll)

Składnia

'Deklaracja
Public Sub New ( _
    name As String _
)
'Użycie
Dim name As String

Dim instance As New Server(name)
public Server(
    string name
)
public:
Server(
    String^ name
)
new : 
        name:string -> Server
public function Server(
    name : String
)

Parametry

Uwagi

Użyj tego konstruktora podczas wystąpienia wymagane SQL Server jest nie lokalne, wystąpienie domyślne.Tej metoda można użyć po SQL Server wystąpienie jest lokalny, ale nie stanowi domyślnej instalacji.Tej metoda można użyć również zdalnego wystąpienia SQL Server.

Przykłady

Visual Basic

'Connect to a remote instance of SQL Server.
Dim srv As Server
'The strServer string variable contains the name of a remote instance of SQL Server.
srv = New Server(strServer)
'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.

PowerShell

#the strServer string variable contains the name of a remote instance of SQL Server.
$srv = new-object Microsoft.SqlServer.Management.Smo.Server($strServer)
#The actual connection is made when a property is retrieved.
Write-Host $srv.Information.Version