我如何通过DTEXEC实用程序命令行参数使用C#语法的Process.Start? [英] How do I pass DTEXEC utility command line arguments to process.start using C# syntax?

查看:639
本文介绍了我如何通过DTEXEC实用程序命令行参数使用C#语法的Process.Start?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要通过ASP.NET code传递参数DTEXEC工具。我现在用的的Process.Start()方法来触发SSIS包执行。

I have to pass parameters to DTEXEC utility through ASP.NET code. I am using the process.start() method to trigger the SSIS package execution.

dtexec /file C:\ssis\pkg1.dtsx 
       /conn "MyConnectionManager";"\"Data Source=localhost\TestSQL2008R2;Initial Catalog=ConnDB;Integrated Security=SSPI;\""

字符串2

/file C:\ssis\pkg1.dtsx 
/conn "MyConnectionManager;Data Source=localhost\TestSQL2008R2;Initial Catalog=ConnDB;Integrated Security=SSPI;"

而通过手动dtexec实用工具执行包上面的命令行参数生成的。不过,我需要使用C#通过这个命令行传递给的Process.Start()方法ASP.NET。

The above command line arguments are generated while manually executing the package through DTEXEC utility. However, I need to pass through this command line to process.start() method in ASP.NET using C#.

我怎样才能重新present C#字符串语句中,上面的命令行?换句话说,我如何通过使用 @ 字符躲避特殊字符,并通过有效的语句进程。开始()

How can I represent the above command line within C# string statement? In other words, how do I escape the special characters by making use of @ character and pass a valid statement to process.start()?

推荐答案

逐字字符串可能是最容易使用的硬编码这些字符串。

A verbatim string literal is probably easiest to use for hard coding such strings.

您只需要加倍每内心

@"dtexec /file C:\ssis\pkg1.dtsx /conn ""MyConnectionManager"";""\""Data Source=localhost\TestSQL2008R2;Initial Catalog=ConnDB;Integrated Security=SSPI;\""""";

@"/file C:\ssis\pkg1.dtsx /conn ""MyConnectionManager;Data Source=localhost\TestSQL2008R2;Initial Catalog=ConnDB;Integrated Security=SSPI;""";

通过正规的字符串,则需要逃避每个 \\ 原以 \\ 在他们面前。

With "regular" strings, you would need to escape each " and \ in the original with a \ before them.

这篇关于我如何通过DTEXEC实用程序命令行参数使用C#语法的Process.Start?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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