Crystal 举报。该系统找不到指定的文件
Crystal Report. The System cannot find the file specified
当我点击加载收据时。它显示加载报告归档和内部异常为:
The system cannot find the file specified.
可能是什么问题?早些时候它可以工作,但现在它显示出问题。
public static void loadBillReport(ReportDocument rd, CrystalReportViewer crv, Int32 status, Int32 orderID)
{
try
{
SqlCommand cmd = new SqlCommand("getOrderReport", MainClass.con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@orderID", orderID);
cmd.Parameters.AddWithValue("@status", status);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
rd.Load(Application.StartupPath + "\Reports\billreports.rpt");
rd.SetDataSource(dt);
crv.ReportSource = rd;
crv.RefreshReport();
}
catch (Exception ex)
{
if (rd != null)
{
Console.WriteLine(ex.Message);
rd.Close();
}
MainClass.showMessage(ex.Message, "Error");
}
}
可能在这里找不到文件:
rd.Load(Application.StartupPath + "\Reports\billreports.rpt");
确保文件存在并且 运行 程序的用户可以通过安全权限访问该文件。
此外,rpt 文件是构建的一部分吗? (bin\release) 或 (bin\debug)?
可能编译后的版本没有找到它。
你可以把相对路径改成绝对路径(D:\your\path\Reports\billreports.rpt)来验证这个理论
手动将 .rpt .cs 报告文件和 crystalreportviewrs13 文件夹复制到根文件夹,即
C:/inetpub/wwwroot/{ProjectName}
当我点击加载收据时。它显示加载报告归档和内部异常为:
The system cannot find the file specified.
可能是什么问题?早些时候它可以工作,但现在它显示出问题。
public static void loadBillReport(ReportDocument rd, CrystalReportViewer crv, Int32 status, Int32 orderID)
{
try
{
SqlCommand cmd = new SqlCommand("getOrderReport", MainClass.con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@orderID", orderID);
cmd.Parameters.AddWithValue("@status", status);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
rd.Load(Application.StartupPath + "\Reports\billreports.rpt");
rd.SetDataSource(dt);
crv.ReportSource = rd;
crv.RefreshReport();
}
catch (Exception ex)
{
if (rd != null)
{
Console.WriteLine(ex.Message);
rd.Close();
}
MainClass.showMessage(ex.Message, "Error");
}
}
可能在这里找不到文件:
rd.Load(Application.StartupPath + "\Reports\billreports.rpt");
确保文件存在并且 运行 程序的用户可以通过安全权限访问该文件。
此外,rpt 文件是构建的一部分吗? (bin\release) 或 (bin\debug)?
可能编译后的版本没有找到它。
你可以把相对路径改成绝对路径(D:\your\path\Reports\billreports.rpt)来验证这个理论
手动将 .rpt .cs 报告文件和 crystalreportviewrs13 文件夹复制到根文件夹,即
C:/inetpub/wwwroot/{ProjectName}