zoukankan      html  css  js  c++  java
  • SSIS 动态设置XML配置文件的方法

    在SSIS 2008 中,如果需要在程序中,动态设置配置文件,代码例子如下:

         public void ExecutePkg()
            {
                            try
                {
                    string PackagePath = @"D:\AC\SQL Server\SQL Server Integration Service\TestConnectionCount\TestConnectionCount\Package.dtsx";
                    string PackageConfigPath = @"D:\AC\SQL Server\SQL Server Integration Service\TestConnectionCount\TestConnectionCount\package.dtsconfig";

                    Microsoft.SqlServer.Dts.Runtime.Application app = new Microsoft.SqlServer.Dts.Runtime.Application();
                    Package pkg = app.LoadPackage(PackagePath, null);
                    if (pkg.Configurations.Contains("config")) pkg.Configurations.Remove("config");
                    //这一步必须设置
                        pkg.EnableConfigurations = true;

                        Configuration cfg = pkg.Configurations.Add();
                        cfg.ConfigurationType = DTSConfigurationType.ConfigFile;
                        cfg.ConfigurationString = PackageConfigPath;
                        cfg.Name = "config";
                        cfg.PackagePath = PackagePath;
                        
                        //app.SaveToXml(PackagePath, pkg, null);

                    if (pkg.Execute() != DTSExecResult.Success)
                    {
                       // return;
                    }
                    
                }
                catch (Exception ex)
                {
                    //return;
                }
                
            }
  • 相关阅读:
    macos linux 命令行显示当前全路径方法
    mac 下面使用apidoc 使用
    du 统计文件夹大小
    mac 共享文件和mount挂载数据
    linux与linux、windows之间文件共享的几种方式
    Yaf安装和配置
    设计模式之 里氏替换原则
    设计模式之单一职责原则
    微信支付 遇到问题总结
    bash shell 快捷键
  • 原文地址:https://www.cnblogs.com/yhnxuhbgx/p/2512138.html
Copyright © 2011-2022 走看看