[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

crystal report converted from 1.0 to 4.0 .NET not working

Posted on 2011-10-18
8
Medium Priority
?
207 Views
Last Modified: 2012-05-12
I have inherited a website designed in .NET framework 1.0. I have to convert to new 4.0 NET framework. Everything else works except the crystal report page.

Here is the code for the page:

public distance_grp oRpt = null;
            public wcn_distance_grp wcn_oRpt = null;

            private void Page_Load(object sender, System.EventArgs e)
            {
                  //
                  // Verify access to page
                  //
                  PageAccessManager.VerifyAccessOrRedirectToLogin(this.Page);
                  string sMemberName = this.Session["PageAccessManager.MemberName"].ToString();
                  string sPagename = this.Page.Request.Path;
                  PageAccessManager.LogMemberActivity(sMemberName,sPagename,"READ",null,null,null,null);
                  //
                  // Set up SQL parameters
                  //
                  string stringZipCode = Request.QueryString["ZipCode"];
                  string stringRadius = Request.QueryString["Radius"];
                  string stringSpecialtyCode = Request.QueryString["Specialty"];
                  string stringSpecialtyId = Request.QueryString["SpecialtyId"];
                  string stringClassId = Request.QueryString["ClassId"];
                  string stringClass = Request.QueryString["Class"];
                  //
                  // Set up the titles in the report
                  //
                  string stringTitle1 = stringClass;
                  string stringTitle2 = "Within " + stringRadius + " mile(s) of " +  stringZipCode;
                  
                  //determine where it came from
                  string stringFrom = "";
                  if ( Request.QueryString["fr"] != null)
                        stringFrom = Request.QueryString["fr"];


                  // create the report instance
                  if (stringFrom =="")
                        oRpt = new  distance_grp();
                  else
                        wcn_oRpt = new wcn_distance_grp();
                  

                  // fill dataset
                  string stringConnectionString = Administrator.ConnectionString;
                  SqlConnection connectionInformedCare = new SqlConnection(stringConnectionString);
                  SqlDataAdapter adapterPM = new SqlDataAdapter(); //stringSQLSelect, connectionInformedCare);
                  SqlCommand oCmd = new SqlCommand("procedureProvidersByDistanceGet", connectionInformedCare);
                  oCmd.CommandType  = System.Data.CommandType.StoredProcedure;
                  oCmd.Parameters.Add("@ZipCode", stringZipCode);
                  oCmd.Parameters.Add("@SpecCodeId",stringSpecialtyId);
                  oCmd.Parameters.Add("@ClassCodeId",stringClassId);
                  oCmd.Parameters.Add("@Radius", stringRadius);
                  oCmd.Parameters.Add("@MemberName",this.Session["PageAccessManager.MemberName"].ToString());
                  connectionInformedCare.Open();
                  adapterPM.SelectCommand=oCmd;
                  DataSet dataSet = new DataSet();
                  adapterPM.Fill (dataSet, "procedureProvidersByDistanceGet");
                  connectionInformedCare.Close();
                  connectionInformedCare.Dispose();

            try
            {

                // set report data source
                if (stringFrom != "")
                    wcn_oRpt.SetDataSource(dataSet);
                else
                    oRpt.SetDataSource(dataSet.Tables[0]);
            }
            catch (Exception excp)
            {
                string msg = excp.Message;
                Response.Write(msg);

            }

                  // Set export params
                  CrystalDecisions.Shared.ExportOptions exp = new CrystalDecisions.Shared.ExportOptions();
                  exp.ExportFormatType  = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
                  exp.FormatOptions = new CrystalDecisions.Shared.PdfRtfWordFormatOptions();
                  CrystalDecisions.Shared.ExportRequestContext req = new CrystalDecisions.Shared.ExportRequestContext();
                  req.ExportInfo = exp;

                  CrystalDecisions.Shared.ParameterValues crParameterValues;
                  ParameterFieldDefinitions crParameterFieldDefinitions;
                  ParameterFieldDefinition crParameterFieldDefinition;
   
                  // get field defs collection
                  if (stringFrom == "")
                        crParameterFieldDefinitions = oRpt.DataDefinition.ParameterFields;
                  else
                        crParameterFieldDefinitions = wcn_oRpt.DataDefinition.ParameterFields;
                  
                  // Get fields def
                  crParameterFieldDefinitions.MoveNext();
                  crParameterFieldDefinition = (ParameterFieldDefinition)crParameterFieldDefinitions.Current;
                  
                  // get values collection
                  crParameterValues = crParameterFieldDefinition.CurrentValues;

--------------------------------------------------------

THE ERROR SHOWS UP ON THIS LINE OF CODE
crParameterFieldDefinition = (ParameterFieldDefinition)crParameterFieldDefinitions.Current;

"value does not fall within the expected range "

I'm not sure what's going on here. Please help!
0
Comment
Question by:LilyRock
  • 3
  • 3
  • 2
8 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 36989469
What version of Crystal?
You may have to upgrade.

mlmcc
0
 

Author Comment

by:LilyRock
ID: 36990186
It's now version 13, runtime version 2.0
I'd got this version from SAP website yesterday.

It was built in .NET 1.0 in the back old day.

Thanks
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 36990395
So long s you use VS2010 you should be ok.
Version 13 also known as CR4VS2010, is specifically for use with VS2010.

mlmcc
0
New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

 

Author Comment

by:LilyRock
ID: 36990613
Yes. Indeed. I've got that version and using VS2010.

Do you see anything would give that kind of error? I have searched the nets and not found any answer.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 36990650
I hav enever seen that error.  I don't know what it means.

mlmcc
0
 
LVL 18

Accepted Solution

by:
vasto earned 2000 total points
ID: 36993731
try to use foreach instead of :
                  crParameterFieldDefinitions.MoveNext();
                  crParameterFieldDefinition = (ParameterFieldDefinition)crParameterFieldDefinitions.Current;


something like this:
foreach ( ParameterFieldDefinition pfd in crParameterFieldDefinitions)
{
crParameterValues = pfd.CurrentValues;
....
}
0
 

Author Comment

by:LilyRock
ID: 36994716
Vasto,
Your codes seem to work! Thanks for you help.
0
 
LVL 18

Expert Comment

by:vasto
ID: 36997659
You are welcome :)
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question