Program create xsd for Crystal Report and provide all data on repo


J

JB

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
file
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
"Selected Tables" pane and click "OK".

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:

Dataset:

myDataset = CreateDataset();
MyDataset.WriteXml(@"c:\myData.xml");


Report:

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

CrystalReportViewer1.ReportSource = psReport;
CrystalReportViewer1.DataBind();

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?

Thanks
Jeff
 
Ad

Advertisements

A

Andy O'Neill


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();
rd.Load(Server.MapPath("Reports\\myReport.rpt"));
rd.SetDataSource(dt);

rd.Refresh();
CrystalReportViewer1.ReportSource = rd;
CrystalReportViewer1.RefreshReport();
 
Ad

Advertisements

J

JB

Hello Andy

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

Thanks
Jeff
--
JB


Andy O'Neill said:

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();
rd.Load(Server.MapPath("Reports\\myReport.rpt"));
rd.SetDataSource(dt);

rd.Refresh();
CrystalReportViewer1.ReportSource = rd;
CrystalReportViewer1.RefreshReport();

.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top