【问题标题】:How to fix the "System cannot find the file specified" exception when using BCP使用 BCP 时如何修复“系统找不到指定的文件”异常
【发布时间】:2017-02-17 09:45:03
【问题描述】:

我正在尝试通过我的 C# 应用程序使用 BCP 进行批量复制。这是我需要执行的命令:

var bcpArgs = "EXEC spReportExecutor @Query = 'SELECT * FROM ExpAifaBrosureCommTape', @Parameters = '<Parameters> <DBToUse>sql_converted_absaDR</DBToUse></Parameters>'" queryout "C:\MISAutomationReports\BCP\AifaBrosureCommissionTape.dat" -e"C:\MISAutomationReports\BCP\AifaBrosureCommissionError.txt" -T -c -S [myserver] -d [mydatabase]

我执行命令如下: System.Diagnostics.Process.Start("bcp.exe", bcpArgs);

这在我的本地机器上运行良好,但是当部署到我们的开发/生产服务器时,我得到一个“系统找不到指定的文件”异常。但是,如果我直接在命令行中运行 bcpArgs,则该过程是成功的。

请问我错过了什么?

【问题讨论】:

    标签: c# bcp


    【解决方案1】:

    你必须指定bcp.exe的路径,而不是:

    System.Diagnostics.Process.Start("bcp.exe", bcpArgs)
    

    尝试:

    System.Diagnostics.Process.Start("path\bcp.exe", bcpArgs)
    

    【讨论】:

    • 正如你回答的那样,我就是这么做的!但为什么它会在我的本地机器上工作(不指定 bcp 路径)?
    • 我相信是因为 c# 应用程序和 bcp 工具位于本地计算机上的同一文件夹中
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-13
    相关资源
    最近更新 更多