0
Reply

[SOLVED] Crystal report problem [SOLVED]

Marko Frelih

Marko Frelih

May 3 2010 7:05 AM
2.4k
Hi to all!

I am newbie at visual c# and crystal reports and I have following problem: I created data table adapter and I fill it with some data succesfully. I've also setup source dataset for crystal report object and I cannot see any data in report. What am I doing wrong? Ok, it seems my post is bad. Let me explain the situation:

  1. I've created dataset with one table and two queries
  2. At runtime the dataset is setup ok and in the debug session I get 130k hits from database (which is ok)
  3. The I add (design time) report viewer and tie it's source to previously created and filled dataset
  4. FINNALY, I GET EMPTY REPORT (at runtime) and some weird data in it (design time):
  • In the first column I get some color names (White, Navy, Red, Olive, Yellow, ...) - DATA IS NOT IN DATASET
  • In the second column I get some weird dates - DATA IS NOT IN DATASET
  • In the third column I get day names (Friday, Saturday, ...) - DATA IS NOT IN DATASET
  • In the fourth column I get some strings ("Document Import Tool", "Form", "OLAP", ...) - DATA IS NOT IN DATASET
Where is the report getting data from?!

I think I found something, when I create dataset and all other stuff (Fill method), the table gets filled, but after that the following code gets executed:
         private void SetupReport()
{
this.m_crFilteredMetersDocument = new ReportDocument(); // creates new report document
string reportPath = "C:\\Documents and Settings\\markofr\\Desktop\\CatsPlusPlus\\Reporter\\FilteredMeters.rpt";
this.m_crFilteredMetersDocument.Load(reportPath);
this.m_crFilteredMetersDocument.SetDataSource(this.m_DataSetFilteredMeters);
this.m_crViewerFilteredMeters.ReportSource=m_crFilteredMetersDocument;

this.m_crFilteredMetersDocument.Refresh();
}
and in this.crFilteredMetersDocument the table is empty (zero size). Can someone tell me why??

I have rewritten the code in a fashion:
         private void SetupReport()
{
this.m_crFilteredMetersDocument = new ReportDocument(); // creates new report document
string reportPath = "FilteredMeters.rpt";
this.m_crFilteredMetersDocument.Load(reportPath);
this.m_crFilteredMetersDocument.SetDataSource(this.m_DataSetFilteredMetersDataTable as DataTable);
this.m_crViewerFilteredMeters.ReportSource=m_crFilteredMetersDocument;

this.m_crFilteredMetersDocument.Refresh();
}
And now it works, but can someone tell me why? I need background ...