Reporting with Crystal Reports

Reporting with Crystal Reports

Old forum URL: forums.lhotka.net/forums/t/1764.aspx


MvdHoning posted on Wednesday, November 15, 2006

I am trying to make an report from an csla object with children. I have an Quotation : Csla.ReadOnlyBase with QuotationLines : Csla.ReadOnlyListBase with QuotationLine : Csla.ReadOnlyBase This i want to use to print a report.

I generated a typed dataset for it.

Next i use the following code to fill the object and turn in into an dataset

DocumentBuilder.Library.Quotation myquotation = DocumentBuilder.Library.Quotation.GetQuotation(1, 39907);

            Csla.Data.ObjectAdapter myadd = new Csla.Data.ObjectAdapter();
           
            DataSet myds = new DataSet();
           
            myadd.Fill(myds, myquotation);
            myadd.Fill(myds, myquotation.QuotationLinesCollection);
  
            BuildDocument.SetDataSource( myds );
            crystalReportViewer1.ReportSource = BuildDocument;

No i get an empty report. However i can use:
            string test = myds.Tables[1].Rows[0]["ArticleId"].ToString();
This wil give me the correct articleid from the dataset generated from the QuotationLinesCollection

Also when i leave out the quotationlines fields from the report i do get an report with details from the quotation. So that works. Only when adding the fields for the quotationlines things go wrong.

QuotationLinesCollection is defined as followed:
       QuotationLines _quotationLines;

       
        public QuotationLines QuotationLinesCollection
        {
            get { return _quotationLines; }
            //set { _quotationLines = value; }
        }
And is filled at:
     private void FetchChildren(SafeDataReader dr)
        {
            dr.NextResult();
            _quotationLines = QuotationLines.GetQuotationLines(dr);
        }
In the Quotation : Csla.ReadOnlyBase

Is there an better (and working) way to get this done?

MvdHoning replied on Wednesday, November 15, 2006

I discovered what was wrong as i generated the xsd directly from the database it used quotationline instead of quotationlines so crystal could not get the correct table from the dataset.

Copyright (c) Marimer LLC