Friday, March 9, 2012

Problem listing data

Please tell me what I am doing wrong. I have some problems using Crystal Reports. I have for an example an Access database with a table called "Authors". I connect to the database using the server explorer in VS.NET 2005, I create an OleDbConnection and a DataAdapter. I use the Generate Dataset option from the DataAdapter to generate a Typed DataSet called dataSet1. I load data into the DataSet using the Fill method from the DataAdapter. Then I insert a new Crystal Report Document Using the Wizard and I add as data source From the Project Data/ADO.Net Datasets the dataset1.Authors. I add all the fields from the dataset and I add an Crystal Report Viewer control to the main form. I use the folowing code to set the ReportSource filed of the viewer:

CrystalReport1 cs = new CrystalReport1();
this.crystalReportViewer1.ReportSource = cs;

Ok, when I run the Application the Crystal Report Viewer it lists nothing from the DataSet data. What is wrong?I found a solution by adding a magic line of code:

CrystalReport1 cs = new CrystalReport1();
cs.SetDataSource(this.dataSet11);//here it is!
this.crystalReportViewer1.ReportSource = cs;

No comments:

Post a Comment