【问题标题】:c# execute CMD command "SQLCMD -L" programmatically and get returned results?c#以编程方式执行CMD命令“SQLCMD -L”并获得返回结果?
【发布时间】:2016-04-27 16:00:29
【问题描述】:

这是我的代码,没有输出。 我想要如图所示的实例列表

namespace InstanceList
{
    class Program
    {
        static void Main(string[] args)
        {
            string cmd = "SQLCMD -L" ; 
            System.Diagnostics.Process proc = new System.Diagnostics.Process();
            proc.StartInfo.FileName = "cmd.exe";
            proc.StartInfo.Arguments = cmd; 
            proc.StartInfo.UseShellExecute = false;
            proc.StartInfo.RedirectStandardOutput = true; 
            proc.Start();
            string output = proc.StandardOutput.ReadToEnd();
        }
    }
}

【问题讨论】:

    标签: c# sql-server-2008 ssis sql-server-2012 ssis-2012


    【解决方案1】:

    SQLCMD -L改成/C SQLCMD -L,为什么不直接设置FileName= "sqlcmd"Arguments = "-L"

    【讨论】:

      猜你喜欢
      • 2016-06-20
      • 2016-03-21
      • 1970-01-01
      • 2013-03-27
      • 2020-05-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多