Crystal Report

I

Islam Elkhayat

I have problems with crystal Report... i use SQL query to fill dataGrid, i
use checkboxs to select the column to return and build my query.. I want to
create a report with the data of the datagrid (Use the same Query)

1-How can i bind it to the report??
2- i need more information about working with crystal report in VS.2003..
may i ask 4 good site??
 
B

Bruce Wood

You must generate an XML schema from the query (an XSD file).

When you start Crystal Designer in Visual Studio, indicate your data
source as "More Data Sources -> ADO.NET (XML)" and in the XML file
path, enter the name of your XML schema file (.XSD).

You should then be able to drag across the various ADO.NET tables that
you're going to be using in your report. Be forewarned that Crystal
Designer .NET doesn't like ADO.NET tables that aren't arranged in a
strict hierarchy.

As far as how to call Crystal with your data, once you have the .rpt
file made, here is a quick sketch:

using CrystalDecisions.Shared;
using CrystalDecisions.ReportSource;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Windows.Forms;

ReportDocument crystalDoc = new ReportDocument();
crystalDoc.Load(reportTemplateFileName,
OpenReportMethod.OpenReportByTempCopy);
try
{
crystalDoc.SetDataSource(myDataSet);
try
{
crystalDoc.PrintToPrinter(1, true, 0, 0);
}
catch (Exception ex)
{
MessageBox.Show("Crystal Reports could not print the report.");
}
}
catch (Exception ex)
{
MessageBox.Show("Crystal report did not accept the data set. There
is probably a mismatch between the data in the data set and the XSD
schema used to create the report template.");
}

Yes, I know that we shouldn't catch (Exception), but the MSDN
documentation for Crystal Reports classes and methods do not document
exceptions.
 

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