Configuration.PackagePath Property
Gets or sets the path of the package that the configuration applies to.
네임스페이스: Microsoft.SqlServer.Dts.Runtime
어셈블리: Microsoft.SqlServer.ManagedDTS (in microsoft.sqlserver.manageddts.dll)
구문
‘선언
Public Property PackagePath As String
public string PackagePath { get; set; }
public:
property String^ PackagePath {
String^ get ();
void set (String^ value);
}
/** @property */
public String get_PackagePath ()
/** @property */
public void set_PackagePath (String value)
public function get PackagePath () : String
public function set PackagePath (value : String)
속성 값
A String that contains the path to the package.
예
The following code example creates a package, enables configurations, and enables the export of the configuration file. It adds a new Configuration to the package Configurations collection, and sets several properties. After saving and reloading the package, the configuration properties are displayed.
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Tasks.BulkInsertTask;
namespace configuration_API
{
class Program
{
static void Main(string[] args)
{
// Create a package and set two properties.
Package pkg = new Package();
pkg.EnableConfigurations = true;
pkg.ExportConfigurationFile(@"C:\conf.xml");
// Create a variable object and add it to the
// package Variables collection.
Variable varPkg = pkg.Variables.Add("var", false, "", 100);
varPkg.Value = 1;
string packagePathToVariable = varPkg.GetPackagePath();
// Create a configuration object and add it to the
// package configuration collection.
Configuration config = pkg.Configurations.Add();
// Set properties on the configuration object.
config.ConfigurationString = "conf.xml";
config.Description = "My configuration description";
config.ConfigurationType = DTSConfigurationType.ConfigFile;
config.PackagePath = packagePathToVariable;
// Save the package and its configuration.
Application app = new Application();
app.SaveToXml(@"c:\pkg.xml", pkg, null);
// Reload the package.
Package p1 = app.LoadPackage(@"c:\pkg.xml", null);
// Review the configuration information.
Configurations configs_After = pkg.Configurations;
foreach(Configuration confAfter in configs_After)
{
Console.WriteLine("ConfigurationString is {0}", confAfter.ConfigurationString);
Console.WriteLine("ConfigurationType is {0}", confAfter.ConfigurationType);
Console.WriteLine("CreationName is {0}", confAfter.CreationName);
Console.WriteLine("Description is {0}", confAfter.Description);
Console.WriteLine("Assigned ID is {0}", confAfter.ID);
Console.WriteLine("Name is {0}", confAfter.Name);
}
}
}
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime
Imports Microsoft.SqlServer.Dts.Tasks.BulkInsertTask
Namespace configuration_API
Class Program
Shared Sub Main(ByVal args() As String)
' Create a package and set two properties.
Dim pkg As Package = New Package()
pkg.EnableConfigurations = True
pkg.ExportConfigurationFile("C:\conf.xml")
' Create a variable object and add it to the
' package Variables collection.
Dim varPkg As Variable = pkg.Variables.Add("var", False, "", 100)
varPkg.Value = 1
Dim packagePathToVariable As String = varPkg.GetPackagePath()
' Create a configuration object and add it to the
' package configuration collection.
Dim config As Configuration = pkg.Configurations.Add()
' Set properties on the configuration object.
config.ConfigurationString = "conf.xml"
config.Description = "My configuration description"
config.ConfigurationType = DTSConfigurationType.ConfigFile
config.PackagePath = packagePathToVariable
' Save the package and its configuration.
Dim app As Application = New Application()
app.SaveToXml("c:\pkg.xml", pkg, Nothing)
' Reload the package.
Dim p1 As Package = app.LoadPackage("c:\pkg.xml", Nothing)
' Review the configuration information.
Dim configs_After As Configurations = pkg.Configurations
Dim confAfter As Configuration
For Each confAfter In configs_After
Console.WriteLine("ConfigurationString is {0}", confAfter.ConfigurationString)
Console.WriteLine("ConfigurationType is {0}", confAfter.ConfigurationType)
Console.WriteLine("CreationName is {0}", confAfter.CreationName)
Console.WriteLine("Description is {0}", confAfter.Description)
Console.WriteLine("Assigned ID is {0}", confAfter.ID)
Console.WriteLine("Name is {0}", confAfter.Name)
Next
End Sub
End Class
End Namespace
Sample Output:
The value of variable var = 1
ConfigurationString is conf.xml
ConfigurationType is ConfigFile
CreationName is
Description is My configuration description
Assigned ID is {9CF65E37-0833-44CD-A99D-EBFE38FAB31B}
Name is {9CF65E37-0833-44CD-A99D-EBFE38FAB31B}
Package Path is \Package.Variables[::var]
스레드 보안
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 설치를 위한 하드웨어 및 소프트웨어 요구 사항을 참조하십시오.
참고 항목
참조
Configuration Class
Configuration Members
Microsoft.SqlServer.Dts.Runtime Namespace