【发布时间】:2019-01-06 13:02:17
【问题描述】:
这是我的 .bat 文件,它在命令提示符下工作,但在我的 c# 代码中它不起作用: 这是.bat文件代码:
bcp "select * from %4.att.Attendance where Date <= '%5' " queryout "Attendance.txt" -c -b 200000 -S %1 -U %2 -P %3
bcp "select * from %4.att.PairedAttendnce where Date <= '%5' " queryout "PairedAttendnce.txt" -c -b 200000 -S %1 -U %2 -P %3
bcp "select * from %4.att.PersonDateStructure where Date <= '%5' " queryout "PersonDateStructure.txt" -c -b 200000 -S %1 -U %2 -P %3
bcp "select * from %4.att.dailyResult where Date <= '%5' " queryout "DailyResult.txt" -c -b 200000 -S %1 -U %2 -P %3
bcp "select * from %4.att.WPResult where WPID <= %7 " queryout "WPResult.txt " -c -b 200000 -S %1 -U %2 -P %3
bcp "select * from %4.att.BaseResultCredit where date <= '%5'" queryout "BaseResultCredit.txt" -c -b 200000 -S %1 -U %2 -P %3
bcp "select * from %4.att.Credit where StartDate <= '%5' " queryout "Credit.txt" -c -b 200000 -S %1 -U %2 -P %3
bcp "select * from %4.Wfo.nwfDoc where SDate <= '%5'" queryout "nwfDoc.txt" -c -b 200000 -S %1 -U %2 -P %3
bcp "select * from %4.Sec.Eventlog where REPLACE(LEFT(CONVERT(VARCHAR, CreateDateTime, 120), 10), '-', '/') <= '%6' " queryout "Eventlog.txt" -c -b 200000 -S %1 -U %2 -P %3
bcp "select * from %4.Cms.DDLLog where REPLACE(LEFT(CONVERT(VARCHAR, PostTime, 120), 10), '-', '/') <= '%6' " queryout "DDLLog.txt" -c -b 200000 -S %1 -U %2 -P %3
这是c#代码:
string MyBatchFile = System.IO.Directory.GetCurrentDirectory() + @"\BatchFiles\Export.bat";
var process = new System.Diagnostics.Process();
DateTime dt = PersianDate.ConvertDate.ToEn (dateOfArchive);
process.StartInfo.FileName = MyBatchFile;
// process.StartInfo.Arguments = String.Format("\"{0}\"", serverDBIP, ServerDbUserName, ServerDbPassword, ServerDBName, dateOfArchive, dt.ToShortDateString(), wpid);
process.StartInfo.Arguments = String.Format("\"{0}\"\"{1}\"\"{2}\"\"{3}\"\"{4}\"\"{5}\"\"{6}\"",
serverDBIP, ServerDbUserName, ServerDbPassword, ServerDBName, dateOfArchive,dt.ToShortDateString(), wpid);
process.StartInfo.RedirectStandardError = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.UseShellExecute = false;
bool b = process.Start();
Thread.Sleep(20000);
//string errorMessage = process.StandardError.ReadToEnd();
process.WaitForExit();
//string outputMessage = process.StandardOutput.ReadToEnd();
//process.WaitForExit();
process.Close();
return b;
有人知道为什么代码不起作用吗?
【问题讨论】:
-
“不起作用”不是错误消息或问题陈述。请提供关于正在发生的事情的完整、清晰、详细的信息。
-
我的意思是执行代码后没有创建文本文件
-
您遇到错误了吗?一定有什么。我们无法像这样为您提供帮助.. 我们需要了解更多关于上下文的信息
-
请编辑问题以包含您拥有的任何额外信息。我们需要的远不止这些。请阅读stackoverflow.com/help/how-to-ask 以了解您可能想要包含的信息类型,以及如何组织您的问题。我们想帮助你,但我们不能不知道更多。请记住:我们无法读取您的屏幕、磁盘……或您的思想!谢谢。
-
不幸的是我没有收到任何错误或异常