您可以从.NET的SSIS任务吗? [英] Can you run an SSIS task from .net?

查看:159
本文介绍了您可以从.NET的SSIS任务吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安排其运行的SSIS包SQL代理任务。我希望能够从.NET运行SSIS包。有没有一种方法,以直接或至少运行SSIS包运行SQL代理任务这又将运行SSIS包。

I have scheduled sql agent task which runs an SSIS package. I want to be able to run the SSIS package from .net. Is there a way to either run the SSIS package directly or at least run the SQL agent task which would in turn run the SSIS package.

如果它有助于它是一个.NET 3.5的Web应用程序用C#编写

If it helps it is for a .net 3.5 web app written in C#

谢谢!

推荐答案

可用来运行SSIS包的选项是 -

The options that are available to run a SSIS package are -

    使用SSIS对象模型编程
  • 运行包。这是在这里联机丛书详细讨论。
  • Run package programmatically using SSIS Object Model. This is discussed in details in Books Online here.

一个例子:

using System;
using Microsoft.SqlServer.Dts.Runtime;

namespace RunFromClientAppCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string pkgLocation;
            Package pkg;
            Application app;
            DTSExecResult pkgResults;

            pkgLocation = "<package path>\CalculatedColumns.dtsx";
            app = new Application();
            pkg = app.LoadPackage(pkgLocation, null);
            pkgResults = pkg.Execute();

            Console.WriteLine(pkgResults.ToString());
            Console.ReadKey();
        }
    }
}

  • 开始DTEXEC.EXE过程。 DTEXEC是命令行实用程序来执行SSIS包。看到它的命令行选项这里

    使用SQL代理。您可以配置一个代理作业运行程序包(手动做提前如果包是静态的,或以编程方式使用SMO或只使用运行包之前SQL存储过程),然后使用SMO或sp_start_job启动编程。

    Use SQL Agent. You can configure an Agent job to run your package (either do it manually in advance if the package is static, or programmatically using SMO or using SQL stored procedures just before running the package), and then start it programmatically using SMO or sp_start_job.

    使用其他实用程序来启动DTEXEC你。

    Use some other utility to start DTEXEC for you.

    创建一个自定义的应用程序,将(在方法#1中描述,或使用DTEXEC如方法#2或者使用OM)运行包。其公开为Web服务或DCOM类,从你的程序中调用该服务。

    Create a custom application that will run the package (either using OM as described in method #1, or using DTEXEC as in method #2). Expose it as a web service or DCOM class, call this service from your program.

    发明自己:)

    参考:<一href="http://blogs.msdn.com/michen/archive/2007/03/22/running-ssis-package-programmatically.aspx">Running SSIS包编程

    这篇关于您可以从.NET的SSIS任务吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆