Web アプリケーションで Crystal Reports を使用しています。私の問題は、EnableDatabaseLogonPrompt="true" と EnableParameterPrompt="true" を保持し、プロンプト ボックスに情報を提供すると、レポートが正常に機能することです。しかし、それらをfalseのままにしてコードビハインドから情報を提供すると、常に「Missing Param Values」または「Database Logon Failed」というエラーが発生します。
私のコードは以下の通りです:
Aspx ファイル:
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server"
AutoDataBind="True"
GroupTreeImagesFolderUrl="" Height="1202px"
ReportSourceID="CrystalReportSource1" ReuseParameterValuesOnRefresh="True"
ToolbarImagesFolderUrl="" ToolPanelWidth="200px" Width="903px"
ToolPanelView="None" EnableDatabaseLogonPrompt="False"
EnableParameterPrompt="False" />
<CR:CrystalReportSource ID="CrystalReportSource1" runat="server">
<Report FileName="CrystalReport1.rpt">
</Report>
</CR:CrystalReportSource>
コードビハインド:
ReportDocument reportDocument = new ReportDocument();
reportDocument.Load(Server.MapPath("~/CrystalReport1.rpt"));
string s=@"4EVER3-PC\MSSQLSERVER2";
reportDocument.SetDatabaseLogon("db", "pwd", s, "databasename", true);
reportDocument.SetParameterValue("@bankACId", "0");
reportDocument.SetParameterValue("@fromDate", "4/11/2011 17:01:57");
reportDocument.SetParameterValue("@todate", "4/11/2014 17:01:57");
CrystalReportViewer1.ReportSource = reportDocument;
CrystalReportViewer1.RefreshReport();
このコードの何が問題なのか指摘してください。それは私を夢中にさせています。