如何在c#中获取bcp命令行返回值 [英] How to get bcp command line return value in c#

查看:287
本文介绍了如何在c#中获取bcp命令行返回值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在应用bcp命令来获取特定的表记录,它运行正常并且还生成一个bcp文件。但我想要返回值(即如何复制行)。



有人能告诉我如何从命令提示符获取该值吗?

提前谢谢。

解决方案

 System.Diagnostics.ProcessStartInfo procStartInfo = 
new System.Diagnostics.ProcessStartInfo(cmd ,/ c+bcp Oceanic.dbo。+ dBname +out C:\\ProgramData \\Oceanic\\+ filename + - U username -P password -n);
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
procStartInfo.CreateNoWindow = true;
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = procStartInfo;
proc.Start();
string result = proc.StandardOutput.ReadToEnd();





查看此信息以获取有关BCP命令的更多信息

BCP [ ^ ]


I am applying bcp command to get particular table record, it is working perfectly and also generating a bcp file. But i want the return value (ie how may rows are copied).

can anyone tell me how to get that value from command prompt?
Thanks in advance.

解决方案

System.Diagnostics.ProcessStartInfo procStartInfo =
                    new System.Diagnostics.ProcessStartInfo("cmd", "/c " + "bcp Oceanic.dbo." + dBname + " out C:\\ProgramData\\Oceanic\\" + filename + " -U username -P password -n");
                procStartInfo.RedirectStandardOutput = true;
                procStartInfo.UseShellExecute = false;
                procStartInfo.CreateNoWindow = true;
                System.Diagnostics.Process proc = new System.Diagnostics.Process();
                proc.StartInfo = procStartInfo;
                proc.Start();
                string result = proc.StandardOutput.ReadToEnd();



Check this out for more information related to BCP command
BCP[^]


这篇关于如何在c#中获取bcp命令行返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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