Skip to Content
0
Former Member
Jul 11, 2009 at 06:17 AM

error:Value does not fall within the expecte

73 Views

i want to creat dynamic report .

when i want to add object field to rpt error occurd.

my code is this:

CRAXDDRT.ApplicationClass CrAppl = new CRAXDDRT.ApplicationClass();

CRAXDDRT.Report CrReport = CrAppl.NewReport();

SqlConnection cnn;

SqlDataAdapter da;

DataSet ds;

try

{

CrReport.PaperSize = CRAXDDRT.CRPaperSize.crPaperA3;

CrReport.PaperOrientation = CRAXDDRT.CRPaperOrientation.crLandscape;

CrReport.PaperSource = CRAXDDRT.CRPaperSource.crPRBinLargeCapacity;

string connectionString = ConfigurationManager.ConnectionStrings["dbServiceConnectionString"].ToString().Trim();

cnn = new SqlConnection(connectionString);

string sqlString = "SELECT xSectionId_pk,xSectionName FROM GLB_TB_Section";

da = new SqlDataAdapter(sqlString, cnn);

ds = new DataSet();

da.Fill(ds, "GLB_TB_Section");

CrReport.Sections[1].AddTextObject("ReportHeader", Convert.ToInt32(Txt_ReportHeaderLeft.Text), Convert.ToInt32(Txt_ReportHeaderTop.Text), null);

CrReport.Sections[1].AddBoxObject(Convert.ToInt32(Txt_BoxLeft.Text), Convert.ToInt32(Txt_BoxTop.Text), Convert.ToInt32(Txt_BoxRight.Text), Convert.ToInt32(Txt_BoxBottom.Text), null);

CrReport.Sections[2].AddTextObject("PageHeader", Convert.ToInt32(Txt_PageHeaderLeft.Text), Convert.ToInt32(Txt_PageHeaderTop.Text), null);

CrReport.Sections[3].AddTextObject("Detail", 6000, 200, null);

CrReport.Sections[3].AddSpecialVarFieldObject(CRAXDDRT.CRSpecialVarType.crSVTPrintDate,500,200);

CrReport.Sections[3].AddFieldObject("{xSectionId_pk}", 120, 300);

CrReport.SaveAs(Server.MapPath("Reports
Rpt.rpt"), CRAXDDRT.CRReportFileFormat.cr70FileFormat);

CrystalReportViewer1.DisplayToolbar = true;

ReportDocument reportDocument1 = new ReportDocument();

reportDocument1.Load(Server.MapPath("Reports
Rpt.rpt"));

CrystalReportViewer1.ReportSource = reportDocument1;

}

catch (Exception ex)

{

MessageBox.Show(ex.Message);

}

plz help me

thanx