Link to home
Start Free TrialLog in
Avatar of LilyRock
LilyRock

asked on

crystal report converted from 1.0 to 4.0 .NET not working

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!
Avatar of Mike McCracken
Mike McCracken

What version of Crystal?
You may have to upgrade.

mlmcc
Avatar of LilyRock

ASKER

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
So long s you use VS2010 you should be ok.
Version 13 also known as CR4VS2010, is specifically for use with VS2010.

mlmcc
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.
I hav enever seen that error.  I don't know what it means.

mlmcc
ASKER CERTIFIED SOLUTION
Avatar of vasto
vasto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Vasto,
Your codes seem to work! Thanks for you help.
You are welcome :)