要运行包,您可能想使用这个 c# 解决方案:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using dts1=Microsoft.SqlServer.Dts.Runtime.Wrapper;
using System.Timers;
using System.Threading;
using ustimer=System.Windows.Forms;
namespace integration
{
public partial class integration : Form
{
public integration()
{
InitializeComponent();
}
public int c = 0;
public string path = @"c:\users\Package.dtsx";
private void button1_Click(object sender, EventArgs e)
{
dts1.IDTSPackage100 pkg;
dts1.IDTSApplication100 app;
dts1.DTSExecResult pkgResults;
app = new dts1.Application();
pkg = app.LoadPackage(path, true, null);
try
{
pkgResults = pkg.Execute(null, null, null, null, null);
if (pkgResults == dts1.DTSExecResult.DTSER_SUCCESS)
{
MessageBox.Show("works");
}
else
{
MessageBox.Show("failed");
}
}
catch
{
//
}
}
public void run_pkg(string path, bool feedback = true)
{
dts1.IDTSPackage100 pkg;
dts1.IDTSApplication100 app;
dts1.DTSExecResult pkgResults;
app = new dts1.Application();
pkg = app.LoadPackage(path, true, null);
try
{
pkgResults = pkg.Execute(null, null, null, null, null);
if (feedback == true)
{
if (pkgResults == dts1.DTSExecResult.DTSER_SUCCESS)
{ MessageBox.Show("worked"); }
else
{ MessageBox.Show("failed"); }
}
}
catch
{
//
}
}}