【发布时间】:2022-06-23 03:51:59
【问题描述】:
我想要做的是使用这个命令行运行一个 SSIS 包:
/SQL "\"\[PACKAGE_NAME]\"" /SERVER [SERVER NAME] /X86 /CHECKPOINTING OFF /REPORTING E
到目前为止,这是我的代码:
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Data.OleDb;
using System.Threading;
using System.Diagnostics;
namespace blablabla.csproj
{
[Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{
#region VSTA generated code
enum ScriptResults
{
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
};
#endregion
public void Main()
{
// Variables
string targetServerName = Dts.Variables["SSIS_SERVER"].Value.ToString();
string packageExecutionName = "package_folder" + "\"" + "package_name";
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.CreateNoWindow = true;
startInfo.FileName = @"dtexec.exe";
string arguments = @"/SQL " + "\"" + "\\" + packageExecutionName + "\"" + " / SERVER " + Dts.Variables["SSIS_SERVER"].Value.ToString() + " / X86 / CHECKPOINTING OFF / REPORTING E /CONSOLELOG M";
Dts.Variables["SSIS_SERVER"].Value.ToString();
// arguments to dtexec
startInfo.Arguments = arguments;
// begin execution
Process proc = Process.Start(startInfo);
}
}
}
脚本任务运行成功但包本身没有运行,所以代码一定是错误的...
这是我第一次用 C# 编写代码,因此对于任何“微不足道”的错误,我们深表歉意。我在互联网上搜索过,但几乎所有情况都是使用保存包的特定文件夹,然后在那里运行包,但我需要的是使用这个特定的命令行运行。
感谢您的宝贵时间。
【问题讨论】:
标签: c# sql visual-studio ssis