我有一个SQL数据库和一个ASP.NET网站,用于将数据放入数据库。在ASP.NET中报告
其中一个项目的要求是建立一个系统,让用户上传Crystal报表服务器,并根据需要运行它。通过这种方式,用户可以创建一个定制的报告(然后转变为管理层,客户),而不会强迫他们通过开发人员。
我在寻找如何完成此目标的建议。
目前,我正在寻找一种方法来重定向从它与该数据库最终将运行在开发数据库中的水晶报表数据库连接。然而,似乎没有一种简单的方法来做到这一点。
我还在研究ReportViewer对象。但是,我所看到的所有代码都涉及在代码中指定报告的查询,这是不可接受的。
一个选项(这是我不喜欢的话),就是让他们写自己的查询,这样他们就可以将结果复制到Excel中。这将意味着一个空白的文本框和关于数据库结构的信息。由于多种原因,这不是一个好主意。
另一种选择是为每个表(或者再加上一些额外的)一个报告,让用户复制他们希望到Excel中的数据,并继续自己快乐的方式。
tl; dr如何建立灵活的报告系统?
=========================================
继续: 2012年8月20日
我决定去b.pell的扩展方法的路线。到目前为止,它比其他任何东西都更接近我。我的代码绑定到CrystalReportViewer如下:
CrystalReportSource rs = new CrystalReportSource();
rs.Report.FileName = Server.MapPath("ReportFiles/") + Request["reportname"];
string connstring = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString;
rs.ReportDocument.ApplyCredentialsFromConnectionString(connstring);
rs.ReportDocument.ApplyNewDatabaseName("myDBName", "mySchemaName");
rs.ReportDocument.Refresh();
CrystalReportViewer1.ReportSource = rs;
这非常接近工作。它工作正常,我的开发机器上,但是当我在服务器上运行的代码,它提供了以下错误:
Logon failed.Error in File CrystalReport2 {5D2E82E5-783E-4DFD-A770-C8AE72A51E4E}.rpt: Unable to connect: incorrect log on parameters. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Runtime.InteropServices.COMException: Logon failed.Error in File CrystalReport2 {5D2E82E5-783E-4DFD-A770-C8AE72A51E4E}.rpt: Unable to connect: incorrect log on parameters. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
的错误是在这行代码:
crTable.Location = String.Format("{0}{1}", prefix, crTable.Location.Substring(crTable.Location.LastIndexOf(".") + 1))
当我删除对ApplyNewDatabaseName的调用,我被要求输入服务器名称,数据库名称,用户名和密码或选择集成安全性。我无法输入数据库名称或服务器名称(这些字段被禁用)。
有什么想法?
Reporting Services听起来像它可能工作。你有一个建议的教程,让我开始? – Brynne 2012-08-16 21:11:51
@notkilroy还没看过,但我认为这是一个教程[Reporting Services](https://www.microsoftvirtualacademy.com/tracks/breakthrough-insights-using-microsoft-sql-server-2012-reporting-services) – saul672 2012-08-16 21:29:47