共用方式為


Application.GetRunningPackages(String) Method

Definition

Returns a RunningPackages collection that contains RunningPackage objects. This property is read-only.

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

Parameters

server
String

The instance of SQL Server that the application is running on.

Returns

A RunningPackages collection that contains the RunningPackage objects that represent all the packages that are currently executing on the computer.

Examples

The following code example shows how to retrieve the collection of running packages from the application object, and then iterate over each package, displaying the InstanceID, PackageID, PackageDescription, PackageName, and UserName.

//...  
//   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.  

Remarks

Administrators see all packages that are currently running on the computer; other users see only those packages that they have started.

Applies to