.NET Framework - Program create xsd for Crystal Report and provide all data on repo

Asked By JB on 06-Apr-10 06:26 PM
Hello Community

I am using C# and ASP.net .Net Framework 3.5 and an embedded
Crystal Report in the web application  will be created from a Dataset.xsd
that I create programmatically on the fly .

When creating the Crystal Report rpt file using the "Database Expert" ,
under "Create New Connection, Database Files" it shows "NewDataSet" and
under it the default name "Table"  after the appl creates the dataset.

Next I use the carat to move the table named "Table" over to the

I can see the fields in the table within the Dataset so I move
the fields into the Details pane of Crystal Report .

After that I make sure I can see the xml file that is created on
the c: drive.

Now I save the file and run the application.

The problem is that  only the first 2 rows from the Dataset/xml
file show up on the report.

The following is code for how the dataset and report is created:


myDataset = CreateDataset();


ReportDocument psReport = new ReportDocument();
string reportPath = Server.MapPath("myData.rpt");
objReport.ReportLogin(psReport);  Note: this line provides credentials

CrystalReportViewer1.ReportSource = psReport;

Am I connecting the rpt file and Dataset correctly?
What can I do to make this report show all rows?
Do I have to delete the xml everytime the DataSet is created?



Andy O'Neill replied to JB on 07-Apr-10 05:12 AM
This code substitutes a datatable for the crystal report's datasource.
If you must have a dataset then DataTable dt = myDataset.Tables[0];

ReportDocument rd;
//  Tricky bit here is to make the name of the datatable match what
the report expects
dt.TableName = "DataTable1";
rd = new ReportDocument();

CrystalReportViewer1.ReportSource = rd;
JB replied to Andy O'Neill on 07-Apr-10 09:08 PM
Hello Andy

It works!  Crystal Reports is reading the whole file.  I had to make the
xml file the datasource.