【发布时间】:2021-01-26 08:40:50
【问题描述】:
我使用 c# 和 SQL Server Management Studio 创建了库存管理系统。在我的系统中有水晶报表。当我在客户端机器上运行我的项目时。它的工作符合预期。但我无法打开水晶报表。原因是给定路径与客户端机器路径不同。
reportDocument.Load(@"E:\Projects\WCC-StockManagementSystem\WCC-StockManagementSystem\Reports\InvoiceReport.rpt");
我想在不提供完整路径的情况下运行我的水晶报表。我想像这样改变上面的行。
reportDocument.Load(@"WCC-StockManagementSystem\WCC-StockManagementSystem\Reports\InvoiceReport.rpt");
但如果我这样做。它不工作。你能告诉我如何解决这个问题。这是我加载水晶报表的完整代码。
reportDocument.Load(@"E:\Projects\WCC-StockManagementSystem\WCC-StockManagementSystem\Reports\InvoiceReport.rpt");
using (SqlConnection con = new SqlConnection(CS))
{
DataSet ds = new DataSet();
SqlDataAdapter sda = new SqlDataAdapter("select MAX(InvoiceNo) InvoiceNo, MAX(Cashier) Cashier, ItemName, Sum(Quantity) Quantity, ItemCode, MAX(DiscountPrice) DiscountPrice, MAX(Amount) Amount, MAX(GrossAmount) GrossAmount, MAX(Cash) Cash, MAX(Balance) Balance, MAX(NoOfItems) NoOfItems from tblTemporaryInvoice group by ItemCode, ItemName ", con);
DataTable dt = new DataTable();
sda.Fill(dt);
reportDocument.SetDataSource(dt);
crvInvoiceReportViewer.ReportSource = reportDocument;
}
请更改此代码并将正确的方法发送给我以在客户端计算机上运行水晶报告。谢谢
【问题讨论】:
-
这个问题与水晶报表没有太大关系,但与您如何分发应用程序以及报表文件文件所在的位置有很大关系。例如,检查this answer
-
每个应用程序都必须配置成功执行所需的信息。您应该使用您打算存储报告的适当目录对其进行配置,就像您对数据库的连接信息所做的那样。
标签: c# sql-server crystal-reports sql-server-2017-express