Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > Crystal Reports
|
Crystal Reports General discussion about Crystal Reports. For discussions specific to the book Professional Crystal Reports for VS.NET, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Crystal Reports section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 13th, 2006, 12:00 PM
Authorized User
 
Join Date: Oct 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default Crystal reports error : Index was out of range.

I am trying to running a crystal report 8.0 in .NET C# based on a Oracle stored procedure that accepts two parameters. I get this error "Index
was out of range. Must be non-negative and less than the size of the
collection. Parameter name: index" on the line: crParameterField1 =
CrystalReportViewer3.ParameterFieldInfo[0];.
Here is my code:

protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer3;
OracleReport3 crReportDocument = new OracleReport3();

TableLogOnInfo crTableLogOnInfo = new TableLogOnInfo();
ConnectionInfo crConnectionInfo = new ConnectionInfo();

//Crystal Report Properties
protected CrystalDecisions.CrystalReports.Engine.Database crDatabase;
protected CrystalDecisions.CrystalReports.Engine.Tables crTables;
protected ParameterFields crParameterFields;
protected ParameterField crParameterField1;
protected ParameterField crParameterField2;
protected ParameterValues crParameterValues;
protected ParameterDiscreteValue crParameterDiscreteValue1;
protected ParameterDiscreteValue crParameterDiscreteValue2;

private void Page_Load(object sender, System.EventArgs e)
{
string empid, perm;
empid = (string)Session["empid"];
perm = (string)Session["perm"];
crConnectionInfo.UserID = "userid";
crConnectionInfo.Password = "password";
crDatabase = crReportDocument.Database;
crTables = crDatabase.Tables;

foreach(CrystalDecisions.CrystalReports.Engine.Tab le crTable in crTables)
            {
                crTableLogOnInfo = crTable.LogOnInfo;
                crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
                crTable.ApplyLogOnInfo(crTableLogOnInfo);
            }

CrystalReportViewer3.ReportSource= crReportDocument;
crParameterField1 = CrystalReportViewer3.ParameterFieldInfo[0];
crParameterField2 = CrystalReportViewer3.ParameterFieldInfo[1];
crParameterDiscreteValue1 = new ParameterDiscreteValue();
crParameterDiscreteValue2 = new ParameterDiscreteValue();
crParameterDiscreteValue1.Value = "emp_id";
crParameterDiscreteValue2.Value = "emp_perm";
crParameterField1.CurrentValues.Add(empid);
crParameterField2.CurrentValues.Add(perm);
        }

Can someone please help?






Similar Threads
Thread Thread Starter Forum Replies Last Post
Index was out of range. Must be non-negative raghavendra_das ASP.NET 2.0 Professional 0 July 24th, 2008 08:16 AM
index out of range datagrid muchengeti ASP.NET 2.0 Professional 0 April 21st, 2006 12:43 PM
Index Out of range exception PbsiGuru General .NET 3 March 22nd, 2004 11:04 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.