Print Page | Close Window

Exception Details: System.ArgumentOutOfRangeExcept

Printed From: Crystal Reports Book
Category: Crystal Reports .NET 2003
Forum Name: Data Connectivity
Forum Discription: How to connect to data sources and export reports
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=1218
Printed Date: 15 May 2024 at 1:31am


Topic: Exception Details: System.ArgumentOutOfRangeExcept
Posted By: dugfmjamul
Subject: Exception Details: System.ArgumentOutOfRangeExcept
Date Posted: 22 Aug 2007 at 1:07pm

Crystal Reports for .NET users,

 

Does any know the why the following error is displayed?

 

Error breaks on pf = pfs["@Country"] :

Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.

Source Error:


Line 96:    ParameterDiscreteValue spValue;   
Line 97:    pfs = crv1.ParameterFieldInfo; 
Line 98:    pf = pfs["@Country"];
Line 99:    spValue = new ParameterDiscreteValue();
Line 100:   spValue.Value = cboCountry.SelectedItem.Text;
 
Code:

crv1.ReportSource = (ReportDocument)Session["REPORT"];
crv1.LogOnInfo = new TableLogOnInfos();
TableLogOnInfo MyLogonInfo = new TableLogOnInfo();
MyLogonInfo.TableName = "up_Customers;1";
MyLogonInfo.ConnectionInfo.DatabaseName = "xtreme";
MyLogonInfo.ConnectionInfo.ServerName = "SVRNAME";
MyLogonInfo.ConnectionInfo.UserID="User1";
MyLogonInfo.ConnectionInfo.Password="Pa$$word1";
crv1.LogOnInfo.Add(MyLogonInfo);
ParameterFields pfs;
IParameterField pf;
ParameterDiscreteValue spValue;   
pfs = crv1.ParameterFieldInfo; 
pf = pfs["@Country"];
spValue = new ParameterDiscreteValue();
spValue.Value = cboCountry.SelectedItem.Text;
pf.CurrentValues.Add(spValue);
Session["REPORT"] = rpt;

 

Report based on the following SQL Command:


DECLARE @RC int
DECLARE @Country varchar(50)
SET @Country = 'USA'
EXEC @RC = [xtreme].[dbo].[up_Customers] @Country

 

Stored Procedure on SQL Server xtreme database:

ALTER  PROCEDURE up_Customers
@Country varchar(50)
AS
SELECT [Customer Name],Address1,City,Region,Country,[Postal Code],Phone
FROM Customer
WHERE Country = @Country
ORDER BY Country, Region, [Customer Name]

 

Any help would be greatly appreciated, thanks in advance.

 

dugfmjamul

 

 



-------------
dugfmjamul



Replies:
Posted By: BrianBischof
Date Posted: 22 Aug 2007 at 1:48pm
Take the "@" out of the parameter name and see if that works.

-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>


Posted By: dugfmjamul
Date Posted: 22 Aug 2007 at 2:35pm

Brian,

Thanks for the quick response time and no, it does not work. I still get the following error.

Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.

Source Error:

Line 94: crv1.LogOnInfo.Add(MyLogonInfo);
Line 95: ParameterFields pfs = crv1.ParameterFieldInfo; 
Line 96: IParameterField pf = pfs["Country"];
Line 97: ParameterDiscreteValue spValue;    
Line 98: spValue = new ParameterDiscreteValue();

Code:

ReportDocument newRpt = (ReportDocument)Session["REPORT"];
crv1.ReportSource = newRpt; 
crv1.LogOnInfo = new TableLogOnInfos();
TableLogOnInfo MyLogonInfo = new TableLogOnInfo();
MyLogonInfo.TableName = "up_Customers;1";
MyLogonInfo.ConnectionInfo.DatabaseName = "xtreme";
MyLogonInfo.ConnectionInfo.ServerName = "SERVERNAME";
MyLogonInfo.ConnectionInfo.UserID="user";
MyLogonInfo.ConnectionInfo.Password="Password1";
crv1.LogOnInfo.Add(MyLogonInfo);
ParameterFields pfs = crv1.ParameterFieldInfo; 
IParameterField pf = pfs["Country"];
ParameterDiscreteValue spValue;    
spValue = new ParameterDiscreteValue();
spValue.Value = cboCountry.SelectedItem.Text;
pf.CurrentValues.Add(spValue);
Session["REPORT"] = newRpt;

Visual Studio 2003 Debugger:

-crv1.ParameterFieldInfo {CrystalDecisions.Shared.ParameterFields} CrystalDecisions.Shared.ParameterFields
 System.Collections.ArrayList {Count=0} System.Collections.ArrayList
 Item <cannot view indexed property> CrystalDecisions.Shared.ParameterField
 Item <cannot view indexed property> CrystalDecisions.Shared.ParameterField
 Item <cannot view indexed property> CrystalDecisions.Shared.ParameterField
 pf <undefined value> CrystalDecisions.Shared.IParameterField

Notes:
1. As you can see, the CrystalReportsViewer does not list any parameters
2. When I create a parameter in ANY Report document the Enter Parameter Values prompt window does not appear when the report is loaded to select parameter values.
3.  The IParameterField reflects the CrystalReports parameter not the SQL parameter, is that correct?

Once again thanks for your help,
dugfmjamul

 

 



-------------
dugfmjamul



Print Page | Close Window