Package.EnableConfigurations 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置一个值,指示包是否加载配置。
public:
property bool EnableConfigurations { bool get(); void set(bool value); };
[Microsoft.SqlServer.Dts.Runtime.Localization.LocalizablePropertyDescription(typeof(Microsoft.SqlServer.Dts.Runtime.Localized), "EnableConfigurationsDesc")]
public bool EnableConfigurations { get; set; }
[<Microsoft.SqlServer.Dts.Runtime.Localization.LocalizablePropertyDescription(typeof(Microsoft.SqlServer.Dts.Runtime.Localized), "EnableConfigurationsDesc")>]
member this.EnableConfigurations : bool with get, set
Public Property EnableConfigurations As Boolean
属性值
如果包加载配置,则为真;否则,就是假的。
- 属性
示例
以下示例创建一个新包,然后设置 EnableConfigurations 到 true,以及属性。ExportConfigurationFile 示例随后向包中添加一个新配置,并设置若干属性的值。
Package pkg = new Package();
pkg.EnableConfigurations = true;
pkg.ExportConfigurationFile("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();
Configuration config = pkg.Configurations.Add();
config.ConfigurationString = "conf.xml";
config.ConfigurationType = DTSConfigurationType.ConfigFile;
config.PackagePath = packagePathToVariable;
// more code here.
Dim pkg As Package = New Package()
pkg.EnableConfigurations = True
pkg.ExportConfigurationFile("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()
Dim config As Configuration = pkg.Configurations.Add()
config.ConfigurationString = "conf.xml"
config.ConfigurationType = DTSConfigurationType.ConfigFile
config.PackagePath = packagePathToVariable
' more code here.
注解
如果将该属性设置为 false,则包中的持久值将被使用,而不是被加载的配置覆盖。
部署包时,你可以将此 false 设置为最后配置。 然后,当部署后首次运行包时,包值会被配置值覆盖一次。 有关包所使用的配置的更多信息,请参见 创建包配置。