Webアプリケーションのasp.netでCrystalレポートを作成しました。一部の報告はうまくいきます。しかし時にはそうではありません。それは以下の問題を示しています。Crystalレポートインデックスが無効です。 (HRESULTからの例外:0x8002000B(DISP_E_BADINDEX))
Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))
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: Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))
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.
Stack Trace: [COMException (0x8002000b): Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))]
Report_Viewer.Page_Load(Object sender, EventArgs e) +894
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
バージョン情報:Microsoft .NET Frameworkのバージョン:2.0.50727.4927。 ASP.NETのバージョン:2.0.50727.4927
マイVS:VS 2008、データベース:MS SQL Expressの2005、OS:Windows 7の
は私の問題を解決するためのいずれかがあります。..
NB:マイコードは、クラス
public ReportDocument ShowReport(string ReportName, string Parameter1)
{
try
{
cryRpt.Load(ReportName);
cryRpt.SetDatabaseLogon(UserName, Password, ServerName, DatabaseName);
crParameterValues.Clear();
crParameterDiscreteValue.Value = Parameter1;// as like Parameter1
crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields;
crParameterFieldDefinition = crParameterFieldDefinitions["@Parameter1"];
crParameterValues = crParameterFieldDefinition.CurrentValues;
crParameterValues.Add(crParameterDiscreteValue);
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
}
catch (Exception ex)
{
throw ex;
//ShowReport(@"default_report.rpt");
}
//CleareParameter();
return cryRpt;
}
レポートビューアページのロード
protected void Page_Load(object sender, EventArgs e)
{
string ReportName="";
string Parameter1="";
ReportName= Session["ReportName "].ToString();
Parameter1 = Session["Parameter1"].ToString();
}
try
{
if (Session["Parameter2"].ToString() != null)
{
Parameter2 = Session["Parameter2"].ToString();
icount = icount + 1;
}
}
catch (Exception) { }
ReportViewer oReportViewer = new ReportViewer(); // Class file
ReportDocument rptDoc = new ReportDocument();
try
{
rptDoc = oReportViewer.ShowReport(ReportName, Parameter1);
rptDoc = oReportViewer.ShowReport(ReportName, Parameter1,
rptDoc.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, "Report");
CrystalReportViewer1.ReportSource = rptDoc;
}
catch (Exception ex)
{
throw ex;
}
}