473,396 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

CrystalReports: Value does not fall within the expected range.

Hello,

I am trying to show a Crystal Reports 10 Enterprise report in an ASP.NET
page (C#). I can run the report via the admin console just fine. When I try
to show the report, after setting up its parameters, I get:

"Value does not fall within the expected range."

How are people interacting with the Crystal Report viewer to set the
parameters on a report? I haven't found any useful documentation at
BusinessObjects.com or even with the crystal distribution. Following my
closing of this post is the code I use to setup the report for viewing.

Thanks

-- Jake

[ CODE ]

// Setup the crystal enterprise logon information
SessionMgr sm = new SessionMgr();
EnterpriseSession es = sm.Logon(uname, pwd, cms, auth);
//
// Discover the crystal ID of the report to view
//
EnterpriseService service = es.GetService("InfoStore");
InfoStore info = new InfoStore(service);
string query = "Select * From CI_INFOOBJECTS Where SI_PROGID =
'CrystalEnterprise.Report' AND SI_ID=" + ReportID + " AND SI_INSTANCE = 0";
InfoObjects objs = info.Query(query);
//
// Setup the report and parameters.
//
if(objs.Count > 0)
{
// The InfoObjects collection is '1' based, not '0' based.
Report rpt = (Report)objs[1];
EnterpriseService es2 = es.GetService("PSReportFactory");
PSReportFactory ps = (PSReportFactory)es2.Interface;
ReportSource rs = ps.OpenReportSource(rpt.ID);
if(Report.HasParameters)
{
CrystalReportViewer1.ParameterFieldInfo.Clear();
ReportParameters pms = rpt.ReportParameters;
ParameterFields pfs = new ParameterFields();
foreach(ReportParameter rp in pms)
{
ParameterField pf = new ParameterField();
ParameterDiscreteValue pv = new ParameterDiscreteValue();
pf.Name = rp.ParameterName;
// Get the value from the input
string v = ReportQueryControl1.GetValue(rp.ParameterName);
switch(rp.ValueType)
{
case CeReportVariableValueType.ceRVDateTime:
try
{
DateTime dt = DateTime.ParseExact(v, "MM/dd/yyyy HH:mm:ss",
CultureInfo.InvariantCulture, DateTimeStyles.None);
pv.Value = dt; // string.Format("DateTime({0:yyyy,MM,dd,HH,mm,ss})", dt);
pf.ParameterValueType = ParameterValueKind.DateTimeParameter;
}
catch(Exception ex)
{
Trace.Write("Invalid date time format: " + v + " (" + ex.Message + ")");
pv.Value = v;
}
break;
case CeReportVariableValueType.ceRVDate:
try
{
DateTime dt = DateTime.ParseExact(v, "MM/dd/yyyy",
CultureInfo.InvariantCulture, DateTimeStyles.None);
pv.Value = dt; // string.Format("Date({0:yyyy,MM,dd})", dt);
pf.ParameterValueType = ParameterValueKind.DateParameter;
}
catch(Exception ex)
{
Trace.Write("Invalid date format: " + v + " (" + ex.Message + ")");
pv.Value = v;
pf.ParameterValueType = ParameterValueKind.StringParameter;
}
break;
default:
pv.Value = v;
pf.ParameterValueType = ParameterValueKind.StringParameter;
break;
}
if(pv.Value == null && !rp.EnableNullValue)
{
// Ignore undefined values
continue;
}
Trace.Write("ShowCrystalReport(): Report " + rpt.ID + ", [" +
rp.ValueType + "," + pf.ParameterValueType + "," + pf.ParameterValueKind + "]
" + pf.Name + "=" + pv.Value);
pf.CurrentValues.AddValue(pv);
CrystalReportViewer1.ParameterFieldInfo.Add(pf);
}
}
CrystalReportViewer1.EnterpriseLogon = es;
CrystalReportViewer1.ReportSource = rs;
CrystalReportViewer1.Visible = true;

Nov 19 '05 #1
4 11746
What's even more odd is this stack trace from the error:

System.ArgumentException: Value does not fall within the expected range.
at CrystalDecisions.Shared.SharedUtils.ConvertToDecim al(Object value)
at CrystalDecisions.Shared.ParameterValues.AddValue(O bject value)
at AGIA.EnterpriseReports.ViewReport.ShowCrystalRepor t() in
j:\cvsroot\clients\arrowhead\enterprisereporting\w ww\viewreport.aspx.cs:line
381

The report is configured for a Date property (StartBookDate).

-- Jake
"javatopia" wrote:
Hello,

I am trying to show a Crystal Reports 10 Enterprise report in an ASP.NET
page (C#). I can run the report via the admin console just fine. When I try
to show the report, after setting up its parameters, I get:

"Value does not fall within the expected range."

How are people interacting with the Crystal Report viewer to set the
parameters on a report? I haven't found any useful documentation at
BusinessObjects.com or even with the crystal distribution. Following my
closing of this post is the code I use to setup the report for viewing.

Thanks

-- Jake

[ CODE ]

// Setup the crystal enterprise logon information
SessionMgr sm = new SessionMgr();
EnterpriseSession es = sm.Logon(uname, pwd, cms, auth);
//
// Discover the crystal ID of the report to view
//
EnterpriseService service = es.GetService("InfoStore");
InfoStore info = new InfoStore(service);
string query = "Select * From CI_INFOOBJECTS Where SI_PROGID =
'CrystalEnterprise.Report' AND SI_ID=" + ReportID + " AND SI_INSTANCE = 0";
InfoObjects objs = info.Query(query);
//
// Setup the report and parameters.
//
if(objs.Count > 0)
{
// The InfoObjects collection is '1' based, not '0' based.
Report rpt = (Report)objs[1];
EnterpriseService es2 = es.GetService("PSReportFactory");
PSReportFactory ps = (PSReportFactory)es2.Interface;
ReportSource rs = ps.OpenReportSource(rpt.ID);
if(Report.HasParameters)
{
CrystalReportViewer1.ParameterFieldInfo.Clear();
ReportParameters pms = rpt.ReportParameters;
ParameterFields pfs = new ParameterFields();
foreach(ReportParameter rp in pms)
{
ParameterField pf = new ParameterField();
ParameterDiscreteValue pv = new ParameterDiscreteValue();
pf.Name = rp.ParameterName;
// Get the value from the input
string v = ReportQueryControl1.GetValue(rp.ParameterName);
switch(rp.ValueType)
{
case CeReportVariableValueType.ceRVDateTime:
try
{
DateTime dt = DateTime.ParseExact(v, "MM/dd/yyyy HH:mm:ss",
CultureInfo.InvariantCulture, DateTimeStyles.None);
pv.Value = dt; // string.Format("DateTime({0:yyyy,MM,dd,HH,mm,ss})", dt);
pf.ParameterValueType = ParameterValueKind.DateTimeParameter;
}
catch(Exception ex)
{
Trace.Write("Invalid date time format: " + v + " (" + ex.Message + ")");
pv.Value = v;
}
break;
case CeReportVariableValueType.ceRVDate:
try
{
DateTime dt = DateTime.ParseExact(v, "MM/dd/yyyy",
CultureInfo.InvariantCulture, DateTimeStyles.None);
pv.Value = dt; // string.Format("Date({0:yyyy,MM,dd})", dt);
pf.ParameterValueType = ParameterValueKind.DateParameter;
}
catch(Exception ex)
{
Trace.Write("Invalid date format: " + v + " (" + ex.Message + ")");
pv.Value = v;
pf.ParameterValueType = ParameterValueKind.StringParameter;
}
break;
default:
pv.Value = v;
pf.ParameterValueType = ParameterValueKind.StringParameter;
break;
}
if(pv.Value == null && !rp.EnableNullValue)
{
// Ignore undefined values
continue;
}
Trace.Write("ShowCrystalReport(): Report " + rpt.ID + ", [" +
rp.ValueType + "," + pf.ParameterValueType + "," + pf.ParameterValueKind + "]
" + pf.Name + "=" + pv.Value);
pf.CurrentValues.AddValue(pv);
CrystalReportViewer1.ParameterFieldInfo.Add(pf);
}
}
CrystalReportViewer1.EnterpriseLogon = es;
CrystalReportViewer1.ReportSource = rs;
CrystalReportViewer1.Visible = true;

Nov 19 '05 #2
Try following code to assign parameter to CR report:

ParameterDiscreteValue discretevalue = new ParameterDiscreteValue();
discretevalue.Value = objValue; // Assign parameter
ParameterValues values = new ParameterValues();
values.Add(discretevalue);
crReport.DataDefinition.ParameterFields[i].ApplyCurrentValues(values);

HTH

Elton Wang

"javatopia" wrote:
What's even more odd is this stack trace from the error:

System.ArgumentException: Value does not fall within the expected range.
at CrystalDecisions.Shared.SharedUtils.ConvertToDecim al(Object value)
at CrystalDecisions.Shared.ParameterValues.AddValue(O bject value)
at AGIA.EnterpriseReports.ViewReport.ShowCrystalRepor t() in
j:\cvsroot\clients\arrowhead\enterprisereporting\w ww\viewreport.aspx.cs:line
381

The report is configured for a Date property (StartBookDate).

-- Jake
"javatopia" wrote:
Hello,

I am trying to show a Crystal Reports 10 Enterprise report in an ASP.NET
page (C#). I can run the report via the admin console just fine. When I try
to show the report, after setting up its parameters, I get:

"Value does not fall within the expected range."

How are people interacting with the Crystal Report viewer to set the
parameters on a report? I haven't found any useful documentation at
BusinessObjects.com or even with the crystal distribution. Following my
closing of this post is the code I use to setup the report for viewing.

Thanks

-- Jake

[ CODE ]

// Setup the crystal enterprise logon information
SessionMgr sm = new SessionMgr();
EnterpriseSession es = sm.Logon(uname, pwd, cms, auth);
//
// Discover the crystal ID of the report to view
//
EnterpriseService service = es.GetService("InfoStore");
InfoStore info = new InfoStore(service);
string query = "Select * From CI_INFOOBJECTS Where SI_PROGID =
'CrystalEnterprise.Report' AND SI_ID=" + ReportID + " AND SI_INSTANCE = 0";
InfoObjects objs = info.Query(query);
//
// Setup the report and parameters.
//
if(objs.Count > 0)
{
// The InfoObjects collection is '1' based, not '0' based.
Report rpt = (Report)objs[1];
EnterpriseService es2 = es.GetService("PSReportFactory");
PSReportFactory ps = (PSReportFactory)es2.Interface;
ReportSource rs = ps.OpenReportSource(rpt.ID);
if(Report.HasParameters)
{
CrystalReportViewer1.ParameterFieldInfo.Clear();
ReportParameters pms = rpt.ReportParameters;
ParameterFields pfs = new ParameterFields();
foreach(ReportParameter rp in pms)
{
ParameterField pf = new ParameterField();
ParameterDiscreteValue pv = new ParameterDiscreteValue();
pf.Name = rp.ParameterName;
// Get the value from the input
string v = ReportQueryControl1.GetValue(rp.ParameterName);
switch(rp.ValueType)
{
case CeReportVariableValueType.ceRVDateTime:
try
{
DateTime dt = DateTime.ParseExact(v, "MM/dd/yyyy HH:mm:ss",
CultureInfo.InvariantCulture, DateTimeStyles.None);
pv.Value = dt; // string.Format("DateTime({0:yyyy,MM,dd,HH,mm,ss})", dt);
pf.ParameterValueType = ParameterValueKind.DateTimeParameter;
}
catch(Exception ex)
{
Trace.Write("Invalid date time format: " + v + " (" + ex.Message + ")");
pv.Value = v;
}
break;
case CeReportVariableValueType.ceRVDate:
try
{
DateTime dt = DateTime.ParseExact(v, "MM/dd/yyyy",
CultureInfo.InvariantCulture, DateTimeStyles.None);
pv.Value = dt; // string.Format("Date({0:yyyy,MM,dd})", dt);
pf.ParameterValueType = ParameterValueKind.DateParameter;
}
catch(Exception ex)
{
Trace.Write("Invalid date format: " + v + " (" + ex.Message + ")");
pv.Value = v;
pf.ParameterValueType = ParameterValueKind.StringParameter;
}
break;
default:
pv.Value = v;
pf.ParameterValueType = ParameterValueKind.StringParameter;
break;
}
if(pv.Value == null && !rp.EnableNullValue)
{
// Ignore undefined values
continue;
}
Trace.Write("ShowCrystalReport(): Report " + rpt.ID + ", [" +
rp.ValueType + "," + pf.ParameterValueType + "," + pf.ParameterValueKind + "]
" + pf.Name + "=" + pv.Value);
pf.CurrentValues.AddValue(pv);
CrystalReportViewer1.ParameterFieldInfo.Add(pf);
}
}
CrystalReportViewer1.EnterpriseLogon = es;
CrystalReportViewer1.ReportSource = rs;
CrystalReportViewer1.Visible = true;

Nov 19 '05 #3
I do not see any methods that are "DataDefinition" or
ParameterField.ApplyCurrentValues. You might be referring to a version of
Crystal that is not mine? I am using Crystal Enterprise version 10, not CR9
for VS.NET.

The stack trace I posted shows that the values are being applied to the
crystal report visa vie the report viewer's ParameterFieldInfo attribute.

CrystalDecisions.Enterprise.Desktop.Report is the report class I use

CrystalDecisions.Web.CrystalReportViewer is the viewer I use

CrystalDecisions.Web.dll v 10.0.3300.0 is my version

-- Jake
"Elton W" wrote:
Try following code to assign parameter to CR report:

ParameterDiscreteValue discretevalue = new ParameterDiscreteValue();
discretevalue.Value = objValue; // Assign parameter
ParameterValues values = new ParameterValues();
values.Add(discretevalue);
crReport.DataDefinition.ParameterFields[i].ApplyCurrentValues(values);

HTH

Elton Wang

"javatopia" wrote:
What's even more odd is this stack trace from the error:

System.ArgumentException: Value does not fall within the expected range.
at CrystalDecisions.Shared.SharedUtils.ConvertToDecim al(Object value)
at CrystalDecisions.Shared.ParameterValues.AddValue(O bject value)
at AGIA.EnterpriseReports.ViewReport.ShowCrystalRepor t() in
j:\cvsroot\clients\arrowhead\enterprisereporting\w ww\viewreport.aspx.cs:line
381

The report is configured for a Date property (StartBookDate).

-- Jake
"javatopia" wrote:
Hello,

I am trying to show a Crystal Reports 10 Enterprise report in an ASP.NET
page (C#). I can run the report via the admin console just fine. When I try
to show the report, after setting up its parameters, I get:

"Value does not fall within the expected range."

How are people interacting with the Crystal Report viewer to set the
parameters on a report? I haven't found any useful documentation at
BusinessObjects.com or even with the crystal distribution. Following my
closing of this post is the code I use to setup the report for viewing.

Thanks

-- Jake

[ CODE ]

// Setup the crystal enterprise logon information
SessionMgr sm = new SessionMgr();
EnterpriseSession es = sm.Logon(uname, pwd, cms, auth);
//
// Discover the crystal ID of the report to view
//
EnterpriseService service = es.GetService("InfoStore");
InfoStore info = new InfoStore(service);
string query = "Select * From CI_INFOOBJECTS Where SI_PROGID =
'CrystalEnterprise.Report' AND SI_ID=" + ReportID + " AND SI_INSTANCE = 0";
InfoObjects objs = info.Query(query);
//
// Setup the report and parameters.
//
if(objs.Count > 0)
{
// The InfoObjects collection is '1' based, not '0' based.
Report rpt = (Report)objs[1];
EnterpriseService es2 = es.GetService("PSReportFactory");
PSReportFactory ps = (PSReportFactory)es2.Interface;
ReportSource rs = ps.OpenReportSource(rpt.ID);
if(Report.HasParameters)
{
CrystalReportViewer1.ParameterFieldInfo.Clear();
ReportParameters pms = rpt.ReportParameters;
ParameterFields pfs = new ParameterFields();
foreach(ReportParameter rp in pms)
{
ParameterField pf = new ParameterField();
ParameterDiscreteValue pv = new ParameterDiscreteValue();
pf.Name = rp.ParameterName;
// Get the value from the input
string v = ReportQueryControl1.GetValue(rp.ParameterName);
switch(rp.ValueType)
{
case CeReportVariableValueType.ceRVDateTime:
try
{
DateTime dt = DateTime.ParseExact(v, "MM/dd/yyyy HH:mm:ss",
CultureInfo.InvariantCulture, DateTimeStyles.None);
pv.Value = dt; // string.Format("DateTime({0:yyyy,MM,dd,HH,mm,ss})", dt);
pf.ParameterValueType = ParameterValueKind.DateTimeParameter;
}
catch(Exception ex)
{
Trace.Write("Invalid date time format: " + v + " (" + ex.Message + ")");
pv.Value = v;
}
break;
case CeReportVariableValueType.ceRVDate:
try
{
DateTime dt = DateTime.ParseExact(v, "MM/dd/yyyy",
CultureInfo.InvariantCulture, DateTimeStyles.None);
pv.Value = dt; // string.Format("Date({0:yyyy,MM,dd})", dt);
pf.ParameterValueType = ParameterValueKind.DateParameter;
}
catch(Exception ex)
{
Trace.Write("Invalid date format: " + v + " (" + ex.Message + ")");
pv.Value = v;
pf.ParameterValueType = ParameterValueKind.StringParameter;
}
break;
default:
pv.Value = v;
pf.ParameterValueType = ParameterValueKind.StringParameter;
break;
}
if(pv.Value == null && !rp.EnableNullValue)
{
// Ignore undefined values
continue;
}
Trace.Write("ShowCrystalReport(): Report " + rpt.ID + ", [" +
rp.ValueType + "," + pf.ParameterValueType + "," + pf.ParameterValueKind + "]
" + pf.Name + "=" + pv.Value);
pf.CurrentValues.AddValue(pv);
CrystalReportViewer1.ParameterFieldInfo.Add(pf);
}
}
CrystalReportViewer1.EnterpriseLogon = es;
CrystalReportViewer1.ReportSource = rs;
CrystalReportViewer1.Visible = true;

Nov 19 '05 #4
Found a solution:

// Create the document
CrystalDecisions.CrystalReports.Engine.ReportDocum ent myReportDocument;

myReportDocument = new
CrystalDecisions.CrystalReports.Engine.ReportDocum ent();
myReportDocument.EnterpriseLogonInfo.Authenticatio nType = auth;
myReportDocument.EnterpriseLogonInfo.CmsServer = cms;
myReportDocument.EnterpriseLogonInfo.Username =
uname; myReportDocument.EnterpriseLogonInfo.Password = pwd;
myReportDocument.FileName = "ceis://@" + cms + "/#" + ReportID;
myReportDocument.UriIsUserEditable = false;

// Set the logon
[Can only set the logon at this point, after the file name is set]

TableLogOnInfo logon = new TableLogOnInfo();
ConnectionInfo ci = new ConnectionInfo();

myReportDocument.SetDatabaseLogon(ci.UserID, ci.Password, ci.ServerName,
ci.DatabaseName);

CrystalReportViewer1.LogOnInfo.Add(CrystalLogonInf o);

// Set the parameters. I cache the parameter values in a hashtable
// and put that into the session for later use in the Init handler of the
// crystal viewer

foreach(string key in hashParams.Keys)
{
myReportDocument.SetParameterValue(key, hashParams[key]);
}

// Make the report visible

CrystalReportViewer1.ReportSource = myReportDocument;
CrystalReportViewer1.Visible = true;

That did it. To handle postback events from the report viewer, I had to add
an init handler on the report viewer and cache all of the report and logon
params to set them on the viewer in the init handler.

This is also the same sample that is shown in the Using Crystal Reports 10
by Neil Fitzgerald, et. al., via QUE Publishing.

-- Jake

Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: anamika | last post by:
Hi I've created a fresh Crystal Report in Visual Studio .NET 2003. I'm aware of the problem that Crystal Reports .NET have by default. I'm trying to pass a string parameter to my report. If my...
2
by: Suresh | last post by:
Hello All, Can anyone help me with this error? I have developed an application using VB Express Edition. The backend being Oracle XE. The application is been published on the server, installation...
1
by: Nandkumar | last post by:
Currently I am working on Azman. I am using Windows XP professional, I have installed AzMan (Windows 2003 Service Pack-1). I have defined operations, tasks roles in AzMan. Now I want to do access...
4
by: liyanage | last post by:
I recently worked on error handling and three related issues/questions came up. 1.) I am trying to trigger Apache ErrorDocument handlers by setting appropriate HTTP status codes in my PHP...
2
by: gasfusion | last post by:
Hey guys! I'm having some issues with one of my installer packages i compiled with Microsoft Visual Studio 2005. (VB installer is buggy as hell and wouldn't work on half of our machines no matter...
13
by: citizenprice | last post by:
I have three fields in a Union Access Query (ID, Begin_Date, End_Date). I want to modify the query to include a parameter date to be entered by the user and produce a result if the parameter date...
6
by: freeflyer30339 | last post by:
I have been pulling my hair out for a week on this one! In a query using Ms Access 2003, I am trying to group two columns. The third column is the date of the transaction. I would like the query to...
5
by: rinoesc | last post by:
Hello, I'm trying to create a ftp application for Windows Mobile. I'm using VisualStudio 2008 with OpenNETCF Framework for Windows Mobile. I have a problem with the following code... string...
0
by: remya1000 | last post by:
i'm using VB.Net 2005 application program. i'm trying to convert VB6 code to VB.Net 2005. QSockB is DLL file. this is the code i used for VB6. This is code i'm using to create socket, when...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.