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;
                }
                
            }
  • 相关阅读:
    常用的STL
    CString,string,char数组的转换
    linux知识
    十一种通用滤波算法(转)
    修复被勒索病毒cl0p损坏的svn代码
    android shell 转发代理shell示例
    3proxy配置
    windbg调试写dmp,随机名字
    nexus6p刷机注意
    mysql语句学习
  • 原文地址:https://www.cnblogs.com/yhnxuhbgx/p/2512138.html
Copyright © 2011-2022 走看看