Application.LoadPackage 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
加载包。
重载
LoadPackage(String, IDTSEvents) |
从文件系统加载 Package。 |
LoadPackage(String, IDTSEvents, Boolean) |
从文件系统加载 Package 并指定线程模型。 |
LoadPackage(String, IDTSEvents)
从文件系统加载 Package。
public:
Microsoft::SqlServer::Dts::Runtime::Package ^ LoadPackage(System::String ^ fileName, Microsoft::SqlServer::Dts::Runtime::IDTSEvents ^ events);
public Microsoft.SqlServer.Dts.Runtime.Package LoadPackage (string fileName, Microsoft.SqlServer.Dts.Runtime.IDTSEvents events);
member this.LoadPackage : string * Microsoft.SqlServer.Dts.Runtime.IDTSEvents -> Microsoft.SqlServer.Dts.Runtime.Package
Public Function LoadPackage (fileName As String, events As IDTSEvents) As Package
参数
- fileName
- String
包含要加载的包的文件的名称。
- events
- IDTSEvents
一个 IDTSEvents 接口。
返回
所加载的包。
示例
下面的代码示例从文件系统加载包,然后返回包的多个属性。
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\100\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\100\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
示例输出:
Number of configurations = 0
VersionGUID = Microsoft.SqlServer.Dts.Runtime.DtsProperty
ProtectionLevel = EncryptSensitiveWithUserKey
适用于
LoadPackage(String, IDTSEvents, Boolean)
从文件系统加载 Package 并指定线程模型。
public:
Microsoft::SqlServer::Dts::Runtime::Package ^ LoadPackage(System::String ^ fileName, Microsoft::SqlServer::Dts::Runtime::IDTSEvents ^ events, bool loadNeutral);
public Microsoft.SqlServer.Dts.Runtime.Package LoadPackage (string fileName, Microsoft.SqlServer.Dts.Runtime.IDTSEvents events, bool loadNeutral);
member this.LoadPackage : string * Microsoft.SqlServer.Dts.Runtime.IDTSEvents * bool -> Microsoft.SqlServer.Dts.Runtime.Package
Public Function LoadPackage (fileName As String, events As IDTSEvents, loadNeutral As Boolean) As Package
参数
- fileName
- String
包含要加载的包的文件的名称。
- events
- IDTSEvents
一个 IDTSEvents 接口。
- loadNeutral
- Boolean
一个布尔值,指示是否将包加载为中性线程。 如果为 false,则以单元线程的形式加载包。
返回
所加载的包。
示例
下面的代码示例从文件系统加载包,将 loadNeutral
标志设置为 false
,然后返回包的多个属性。
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\100\Samples\Integration Services\Package Samples\ExecuteProcess Sample\ExecuteProcess\UsingExecuteProcess.dtsx";
Application app = new Application();
Package p = app.LoadPackage(pkg, null, false);
// 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\100\Samples\Integration Services\Package Samples\ExecuteProcess Sample\ExecuteProcess\UsingExecuteProcess.dtsx"
Dim app As Application = New Application()
Dim p As Package = app.LoadPackage(pkg,Nothing,False)
' 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
示例输出:
Number of configurations = 0
VersionGUID = Microsoft.SqlServer.Dts.Runtime.DtsProperty
ProtectionLevel = EncryptSensitiveWithUserKey