zoukankan      html  css  js  c++  java
  • 向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();
            }
        }
    }

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

  • 相关阅读:
    mongodb复制集搭建
    mongodb分片集群搭建
    mongodb安装、运行
    吉他“和弦”是什么?
    NoSQL 简介
    淘汰算法 LRU、LFU和FIFO
    Java遍历Map对象的四种方式
    终于搞懂了shell bash cmd...
    如何为openwrt生成补丁
    linux内核启动时报错ubi0 error: validate_ec_hdr: bad data offset 256, expected 128
  • 原文地址:https://www.cnblogs.com/xuf22/p/2283469.html
Copyright © 2011-2022 走看看