Constructeur ServerConnection (SqlConnection)
Initializes a new instance of the ServerConnection class with the specified connection parameters.
Espace de noms : Microsoft.SqlServer.Management.Common
Assembly : Microsoft.SqlServer.ConnectionInfo (en Microsoft.SqlServer.ConnectionInfo.dll)
Syntaxe
'Déclaration
Public Sub New ( _
sqlConnection As SqlConnection _
)
'Utilisation
Dim sqlConnection As SqlConnection
Dim instance As New ServerConnection(sqlConnection)
public ServerConnection(
SqlConnection sqlConnection
)
public:
ServerConnection(
SqlConnection^ sqlConnection
)
new :
sqlConnection:SqlConnection -> ServerConnection
public function ServerConnection(
sqlConnection : SqlConnection
)
Paramètres
- sqlConnection
Type : System.Data.SqlClient.SqlConnection
A SqlConnection system object that specifies connection parameters associated with the referenced connection.
Exemples
C#
String connectionString = "Data Source=(local);Initial Catalog=AdventureWorks2012;Integrated Security=SSPI;";
SqlConnection sqlConnection = new SqlConnection(connectionString);
ServerConnection conn = new ServerConnection(sqlConnection);
Server srv = new Server(conn);
Console.WriteLine(srv.Information.Version);
PowerShell
$connectionString = "Data Source=(local);Initial Catalog=AdventureWorks2012;Integrated Security=SSPI;"
$sqlConnection = new-object System.Data.SqlClient.SqlConnection($connectionString)
$conn = new-object Microsoft.SqlServer.Management.Common.ServerConnection($sqlConnection)
#Connect to the local, default instance of SQL Server
$srv = new-object Microsoft.SqlServer.Management.Smo.Server($conn)
Write-Host $srv.Information.Version
Voir aussi
Référence
Espace de noms Microsoft.SqlServer.Management.Common