• 向SSIS包传参调用


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using DtsManage = Microsoft.SqlServer.Dts.Runtime;
    
    namespace TN.SynthEmployee
    {
        class Program
        {
            static void Main(string[] args)
            {
                string path = System.Configuration.ConfigurationManager.AppSettings["PackagePath"];
                string tableSource = System.Configuration.ConfigurationManager.AppSettings["Temp_ViewHRInfo"];
    
    
                DtsManage.Package package;
                DtsManage.Application dtsApp = new DtsManage.Application();
                package = dtsApp.LoadPackage(path, null);
    
                try
                {
                    Console.WriteLine(DateTime.Now.ToString() + ": Load SSIS Package Success");
    
                    //获取参数类型
                    //SSIS包中的参数以package.Variables["key"]形式获取,其中key为参数名
                    Type t = package.Variables["TableName"].GetType();
                    //参数赋值
                    package.Variables["User::TableName"].Value = Convert.ChangeType(tableSource, t);
    
    
                    DtsManage.DTSExecResult pkgResults = package.Execute();
    
                    if (pkgResults == DtsManage.DTSExecResult.Failure)
                    {
                        Console.WriteLine(DateTime.Now.ToString() + ": DTS Package Run Faild");
                    }
                    else
                    {
                        Console.WriteLine(DateTime.Now.ToString() + ": DTS Package Run Success");
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
                finally {
                    package.Dispose();
                }
                Console.ReadLine();
            }
        }
    }

    曾经年少多少事 而今皆付谈笑中!

  • 相关阅读:
    shell中括号的特殊用法 linux if多条件判断
    uboot kernel 博客
    meson 中调用shell script
    200. 岛屿数量
    9. 回文数
    53. 最大子序和
    394. 字符串解码
    32. 最长有效括号
    leetcode排序的题 912. 排序数组 215. 数组中的第K个最大元素
    c++引用和运算符重载思考
  • 原文地址:https://www.cnblogs.com/xuf22/p/2283469.html
Copyright © 2020-2023  润新知