Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2008
    Posts
    6

    Unanswered: Value does not fall within the expected range.

    Hi to all,

    Am using C# 2005 and Crystal report product version 11.0.0.1282. During run time i want to design the field settings in crystal report detail section. Because my SP return 5 / 8 / 20 column depending upon the situation so no need to design the fields at design time , i like to design the fields at runtime so i select Crystal Reports ActiveX Designer Design and Runtime Library 11.0 from COM, with this dll i write the folowing simple code.

    private void CrystalReportDynamicDataBind()
    {
    CRAXDDRT.ApplicationClass CrAppl = new CRAXDDRT.ApplicationClass();
    CRAXDDRT.Report CrReport; CRAXDDRT.Section crSection; CRAXDDRT.Section crHeaderSection; CRAXDDRT.Section aa; CRAXDDRT.Section bb; CRAXDDRT.Section cc; SqlConnection cnn; SqlDataAdapter da; DataSet ds; try { CrReport = CrAppl.NewReport(); aa = CrReport.Sections[1];
    crSection = CrReport.Sections[2];
    crHeaderSection = CrReport.Sections[3];
    bb = CrReport.Sections[4]; cc = CrReport.Sections[5]; CrReport.PaperSize = CRAXDDRT.CRPaperSize.crPaperA3; CrReport.PaperOrientation = CRAXDDRT.CRPaperOrientation.crLandscape; CrReport.PaperSource = CRAXDDRT.CRPaperSource.crPRBinLargeCapacity; string connectionString = ConfigurationManager.ConnectionStrings["JJConnectionString1"].ToString().Trim(); cnn = new SqlConnection(connectionString); string sqlString = "Select id From Table_1"; da = new SqlDataAdapter(sqlString, cnn); ds = new DataSet(); da.Fill(ds, "Table_1"); CrReport.Sections[2].AddTextObject("id", 4000, 200, null);
    CrReport.Sections[3].AddFieldObject("{id}", 4000, 1000);
    crSection.AddLineObject(0, 0, 1000, 2000, CrReport.Sections[2]); crSection.AddSpecialVarFieldObject(CRAXDDRT.CRSpec ialVarType.crSVTDataDate, 0, 0); crSection.AddSpecialVarFieldObject(CRAXDDRT.CRSpec ialVarType.crSVTDataTime, 1500, 0); crSection.AddSpecialVarFieldObject(CRAXDDRT.CRSpec ialVarType.crSVTFileCreationDate, 3000, 0); crSection.AddSpecialVarFieldObject(CRAXDDRT.CRSpec ialVarType.crSVTFilename, 4000, 0); crSection.AddSpecialVarFieldObject(CRAXDDRT.CRSpec ialVarType.crSVTGroupNumber, 5000, 0); crSection.AddSpecialVarFieldObject(CRAXDDRT.CRSpec ialVarType.crSVTModificationDate, 6000, 0); crSection.AddSpecialVarFieldObject(CRAXDDRT.CRSpec ialVarType.crSVTPageNumber, 7000, 0); CrReport.SaveAs(Server.MapPath("CrystalReport1.rpt "), CRAXDDRT.CRReportFileFormat.cr70FileFormat); CrystalReportViewer1.DisplayToolbar = true; ReportDocument reportDocument1 = new ReportDocument(); reportDocument1.Load(Server.MapPath("CrystalReport 1.rpt")); reportDocument1.SetDatabaseLogon("", "", ".", "JJ"); reportDocument1.SetDataSource(ds); CrystalReportViewer1.ReportSource = reportDocument1; } catch (Exception ex) { throw ex; }
    }

    When i create AddFieldObject then it return the error as following :

    {System.ArgumentException: Value does not fall within the expected range.
    at CRAXDDRT.SectionClass.AddFieldObject(Object Field, Int32 Left, Int32 Top)
    at WebApplication1.DynamicBinding.CrystalReportDynami cDataBind() in D:\Jeyaseelan\DotNetPracticals2005\WebApplication1 \WebApplication1\DynamicBinding.aspx.cs:line 85}

    Could anybody please tell me what is the exact problem. But AddTextObject is working fine. Members please help me. is any coding sample or solution? please let me know.

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Sprocs returning different numbers of columns; doesn't sound too great...
    Have you considered designing your procs like so:
    Code:
    sproc1:
    SELECT col1, col2, col3, col4
    FROM   my_table
    
    sproc2:
    SELECT col1, col2, NULL, NULL
    FROM   my_table2
    and so on (i.e. returning the same number of columns regardless..?

    I'm assuming a fair amount about your set up and sprocs here...
    George
    Home | Blog

  3. #3
    Join Date
    Aug 2008
    Posts
    6
    Hi Georgev,

    Thanks for your nice response.
    As per your answer we should design the CR at design time but what i expect is we design the CR at runtime only and never touch with Sprocs.
    Actualy my problem is during runtime sp return 30 or 40 or or 20 columns, so no need to design the crystal report at design time, design time i just create the blank report and runtime i need to create the TextObject in Headertext and FieldObject in Detail seaction, here AddTextObject created fine but AddFieldObject creation is the only problem. Whenever it meet the line
    CrReport.Sections[3].AddFieldObject("{id}", 780, 0);
    then meet a error
    System.ArgumentException: Value does not fall within the expected range

    Colud you please tell me what is the exact problem?
    Last edited by winseelan; 08-19-08 at 01:02.

  4. #4
    Join Date
    Aug 2008
    Posts
    6

    Value does not fall within the expected range

    Hi to all,
    Am using Asp.Net 2.0 VS.2005 and Crystal report product version 11.0.0.1282. During run time i want to design the field settings in crystal report detail section. Because my SP return 5 / 8 / 20 column depending upon the situation so no need to design the fields at design time , i like to design the fields at runtime so i select Crystal Reports ActiveX Designer Design and Runtime Library 11.0 from COM, with this dll i write the folowing simple code.
    private void CrystalReportDynamicDataBind()
    {
    CRAXDDRT.ApplicationClass CrAppl = new CRAXDDRT.ApplicationClass();
    CRAXDDRT.Report CrReport;
    CRAXDDRT.Section crSection;
    CRAXDDRT.Section crHeaderSection;
    CRAXDDRT.Section aa;
    CRAXDDRT.Section bb;
    CRAXDDRT.Section cc;
    SqlConnection cnn;
    SqlDataAdapter da;
    DataSet ds;
    try
    {
    CrReport = CrAppl.NewReport();
    aa = CrReport.Sections[1];
    crSection = CrReport.Sections[2];
    crHeaderSection = CrReport.Sections[3];
    bb = CrReport.Sections[4];
    cc = CrReport.Sections[5];
    CrReport.PaperSize = CRAXDDRT.CRPaperSize.crPaperA3;
    CrReport.PaperOrientation = CRAXDDRT.CRPaperOrientation.crLandscape; CrReport.PaperSource = CRAXDDRT.CRPaperSource.crPRBinLargeCapacity; string connectionString = ConfigurationManager.ConnectionStrings["JJConnectionString1"].ToString().Trim();
    cnn = new SqlConnection(connectionString);
    string sqlString = "Select id From Table_1";
    da = new SqlDataAdapter(sqlString, cnn);
    ds = new DataSet();
    da.Fill(ds, "Table_1");
    CrReport.Sections[2].AddTextObject("id", 4000, 200, null);
    CrReport.Sections[3].AddFieldObject("{id}", 4000, 1000);
    crSection.AddLineObject(0, 0, 1000, 2000, CrReport.Sections[2]);
    crSection.AddSpecialVarFieldObject(CRAXDDRT.CRSpec ialVarType.crSVTDataDate, 0, 0); crSection.AddSpecialVarFieldObject(CRAXDDRT.CRSpec ialVarType.crSVTDataTime, 1500, 0); crSection.AddSpecialVarFieldObject(CRAXDDRT.CRSpec ialVarType.crSVTFileCreationDate, 3000, 0); crSection.AddSpecialVarFieldObject(CRAXDDRT.CRSpec ialVarType.crSVTFilename, 4000, 0); crSection.AddSpecialVarFieldObject(CRAXDDRT.CRSpec ialVarType.crSVTGroupNumber, 5000, 0); crSection.AddSpecialVarFieldObject(CRAXDDRT.CRSpec ialVarType.crSVTModificationDate, 6000, 0); crSection.AddSpecialVarFieldObject(CRAXDDRT.CRSpec ialVarType.crSVTPageNumber, 7000, 0); CrReport.SaveAs(Server.MapPath("CrystalReport1.rpt "), CRAXDDRT.CRReportFileFormat.cr70FileFormat);
    CrystalReportViewer1.DisplayToolbar = true;
    ReportDocument reportDocument1 = new ReportDocument(); reportDocument1.Load(Server.MapPath("CrystalReport 1.rpt")); reportDocument1.SetDatabaseLogon("", "", ".", "JJ"); reportDocument1.SetDataSource(ds);
    CrystalReportViewer1.ReportSource = reportDocument1;
    }
    catch (Exception ex)
    {
    throw ex;
    }
    }
    When i create AddFieldObject then it return the error as following :
    {System.ArgumentException: Value does not fall within the expected range.
    at CRAXDDRT.SectionClass.AddFieldObject(Object Field, Int32 Left, Int32 Top)
    at WebApplication1.DynamicBinding.CrystalReportDynami cDataBind() in D:\Jeyaseelan\DotNetPracticals2005\WebApplication1 \WebApplication1\DynamicBinding.aspx.cs:line 85}
    Could anybody tell me what is the exact problem. But AddTextObject is working fine. Members please help me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •