473,372 Members | 1,077 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,372 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 11742
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.