Hi,
I made the Crystal Report at home on my laptop. Then when I came to work I tried to run the application on another machine and the report didn't work. I made it again, chose the database, but now it doesn't work well. I get the following error:
Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))
on this row:
cryRpt.SetParameterValue("@br_kas_izvod", textBox1.Text);
The report opens, but without data retrieved from the database.
Previously, when I tested it on the laptop, it asked for enteing a descrete value, and that's why I enetred that row, for sending the parameter from the textbox as a parameter.
Could anybody help me please what might be the problem ?
Thanks in advance.
Loading
NelPosted Aug 31, 2011, 7:46 AM
crystalReportViewer1.SelectionFormula ="{datatable.field} =" +textBox1.Text;
crystalReportViewer1.ReportSource = cryRpt;
and it works good now
Prabhu RajaPosted Aug 31, 2011, 7:43 AM
crpdoc.Load(this.CrystalReportSource1.Report.FileName) //Use Your Crystal Report Source
and
ParameterField paramvalue = this.CrystalReportViewer1.ParameterFieldInfo[0];
NelPosted Aug 31, 2011, 6:58 AM
cryRpt.Load("Bl-JSPT\CrystalReport4.rpt");
it says on that line:"Load report failed." on that line
If I leave as it was before:
@"E:\Documents and Settings\User\Desktop\Bl-JSPT\Bl-JSPT\CrystalReport4.rpt".
I get error:
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
on this line:
ParameterField paramvalue = cryRpt.ParameterFields[0];
NelPosted Aug 31, 2011, 6:43 AM
Prabhu RajaPosted Aug 31, 2011, 6:39 AM
Server.MapPath("CrystalReport4.rpt"); //Server.MapPath() is used to identify your crys.Report
if your application is windows application, Use this
cryRpt.Load("Bl-JSPT\CrystalReport4.rpt");
NelPosted Aug 31, 2011, 6:32 AM
@"E:\Documents and Settings\User\Desktop\Bl-JSPT\Bl-JSPT\CrystalReport4.rpt"
with Server.MapPath if my server name is AQA?
Prabhu RajaPosted Aug 31, 2011, 6:19 AM
make sure, the following namespaces should present at top your class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.Web.Configuration;
Here,
Server.mappath("CrystalReport4.rpt"); function is used identify your crystal report over several crystal Report in the same project.
NelPosted Aug 31, 2011, 6:16 AM
Than, for ParameterField I get: "the type or namespace ParameterField could not be found", and I get the same for ParameterDiscreteValue.
Prabhu RajaPosted Aug 31, 2011, 6:03 AM
private void button1_Click(object sender, EventArgs e)
{
ReportDocument cryRpt = new ReportDocument();
cryRpt.Load(Server.MapPath("CrystalReport4.rpt"));
ParameterField paramvalue = cryRpt.ParameterFields[0];
ParameterDiscreteValue paramvaluedata = new ParameterDiscreteValue();
paramvaluedata.Value = textBox1.Text.Trim();
paramvalue .CurrentValues.Add(paramvaluedata);
crystalReportViewer1.ReportSource = cryRpt;
cryRpt.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape;
crystalReportViewer1.Refresh();
}
Thank You
NelPosted Aug 31, 2011, 5:56 AM
{
ReportDocument cryRpt = new ReportDocument();
cryRpt.Load(@"path\CrystalReport4.rpt");
crystalReportViewer1.ReportSource = cryRpt;
cryRpt.SetParameterValue("@br_kas_izvod", textBox1.Text);
cryRpt.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape;
crystalReportViewer1.Refresh();
}
and this code worked well before, on the laptop.
Prabhu RajaPosted Aug 31, 2011, 5:52 AM