共用方式為


Application.LoadPackage Method (String, IDTSEvents)

Loads a Package from the file system.

命名空間: Microsoft.SqlServer.Dts.Runtime
組件: Microsoft.SqlServer.ManagedDTS (in microsoft.sqlserver.manageddts.dll)

語法

'宣告
Public Function LoadPackage ( _
    fileName As String, _
    events As IDTSEvents _
) As Package
public Package LoadPackage (
    string fileName,
    IDTSEvents events
)
public:
Package^ LoadPackage (
    String^ fileName, 
    IDTSEvents^ events
)
public Package LoadPackage (
    String fileName, 
    IDTSEvents events
)
public function LoadPackage (
    fileName : String, 
    events : IDTSEvents
) : Package

參數

  • fileName
    The name of the file that contains the package to load.

傳回值

The package that was loaded.

範例

The following code example loads a package from the file system, and then returns several properties for the package.

class ApplicationTests
    {
        static void Main(string[] args)
        {
            // The variable pkg points to the location of the
            // ExecuteProcess package sample installed with
            // the SSIS samples.
            string pkg = @"C:\Program Files\Microsoft SQL Server\90\Samples\Integration Services\Package Samples\ExecuteProcess Sample\ExecuteProcess\UsingExecuteProcess.dtsx";

            Application app = new Application();
            Package p = app.LoadPackage(pkg, null);
           // Now that the package is loaded, we can query on
           // its properties.
            int n = p.Configurations.Count;
            DtsProperty  p2 = p.Properties["VersionGUID"];
            DTSProtectionLevel pl = p.ProtectionLevel;

            Console.WriteLine("Number of configurations = " + n);
            Console.WriteLine("VersionGUID = " + p2);
            Console.WriteLine("ProtectionLevel = " + pl);
        }
    }
Class ApplicationTests
        Shared  Sub Main(ByVal args() As String)
            ' The variable pkg points to the location of the
            ' ExecuteProcess package sample installed with
            ' the SSIS samples.
            Dim pkg As String =  "C:\Program Files\Microsoft SQL Server\90\Samples\Integration Services\Package Samples\ExecuteProcess Sample\ExecuteProcess\UsingExecuteProcess.dtsx" 
 
            Dim app As Application =  New Application() 
            Dim p As Package =  app.LoadPackage(pkg,Nothing) 
           ' Now that the package is loaded, we can query on
           ' its properties.
            Dim n As Integer =  p.Configurations.Count 
            Dim p2 As DtsProperty =  p.Properties("VersionGUID") 
            Dim pl As DTSProtectionLevel =  p.ProtectionLevel 
 
            Console.WriteLine("Number of configurations = " + n)
            Console.WriteLine("VersionGUID = " + p2)
            Console.WriteLine("ProtectionLevel = " + pl)
        End Sub
End Class

Sample Output:

Number of configurations = 0

VersionGUID = Microsoft.SqlServer.Dts.Runtime.DtsProperty

ProtectionLevel = EncryptSensitiveWithUserKey

執行緒安全性

Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

平台

開發平台

如需受支援的平台清單,請參閱<安裝 SQL Server 2005 的硬體和軟體需求>。

目標平台

如需受支援的平台清單,請參閱<安裝 SQL Server 2005 的硬體和軟體需求>。

請參閱

參考

Application Class
Application Members
Microsoft.SqlServer.Dts.Runtime Namespace