Application.GetRunningPackages(String) 方法

定义

返回包含 RunningPackages 对象的 RunningPackage 集合。 此属性为只读。

public:
 Microsoft::SqlServer::Dts::Runtime::RunningPackages ^ GetRunningPackages(System::String ^ server);
public Microsoft.SqlServer.Dts.Runtime.RunningPackages GetRunningPackages (string server);
member this.GetRunningPackages : string -> Microsoft.SqlServer.Dts.Runtime.RunningPackages
Public Function GetRunningPackages (server As String) As RunningPackages

参数

server
String

应用程序正在运行的SQL Server实例。

返回

一个 RunningPackages 集合,此集合包含的 RunningPackage 对象表示当前在计算机上执行的所有包。

示例

下面的代码示例演示如何从应用程序对象检索正在运行的包的集合,然后循环访问每个包,并显示InstanceIDPackageIDPackageDescriptionPackageNameUserName

//...  
//   Declare and instantiate objects here.  
Application app = new Application();  
//...  
// Create a RunningPackages collection, named pkgs, and fill it  
// with the running packages from the application object.  
RunningPackages pkgs = app.GetRunningPackages(null);  

// Enumerate over each package in the collection and display some data.  
foreach(RunningPackage package in pkgs)  
    {  
        Console.WriteLine("InstanceID: "+package.InstanceID);  
        Console.WriteLine("PackageDescription: "+package.PackageDescription);  
        Console.WriteLine("PackageID: "+package.PackageID);  
        Console.WriteLine("PackageName: "+package.PackageName);  
        Console.WriteLine("UserName: "+package.UserName);  
    }  
//   Insert more code here.  
'...  
'   Declare and instantiate objects here.  
Dim app As New Application  
'...  
' Create a RunningPackages collection, named pkgs, and fill it  
' with the running packages from the application object.  
Dim pkgs As RunningPackages = app.GetRunningPackages(Nothing)   

' Enumerate over each package in the collection and display some data.  
For Each package As RunningPackage In pkgs  
        Console.WriteLine("InstanceID: " & package.InstanceID.ToString())  
        Console.WriteLine("PackageDescription: " & package.PackageDescription)  
        Console.WriteLine("PackageID: " & package.PackageID.ToString())  
        Console.WriteLine("PackageName: " & package.PackageName)  
        Console.WriteLine("UserName: " & package.UserName)  
Next  
'   Insert more code here.  

注解

管理员会看到当前在计算机上运行的所有包;其他用户仅看到已启动的那些包。

适用于