I have XML and its corresponding XSD file and its report file. All i want is to bind the XML data to the report and export the report as PDF. I am using Visual Studio 2003. The following is the code.
try
{
DataSet dsXml = new DataSet();
dsXml.ReadXml(@"C:\Temp\CONSUMERWO_20000001.xml");
ReportDocument rpt = new ReportDocument();
rpt.Load(@"C:\Temp\CONSUMERWO.rpt");
rpt.SetDataSource(dsXml.Tables[0]);
rpt.ExportToDisk(ExportFormatType.PortableDocFormat, @"C:\Temp\" + Guid.NewGuid().ToString() + ".pdf");
}
catch (Exception Ex)
{
txtMessage.Text = "Exception: " + Ex.Message;
}
Error: Exception: This field name is not known.
Details: errorKind
Error in File C:\DOCUME~1\SENTHI~1.PRA\LOCALS~1\Temp\{CF274BB7-E0F0-40D4-AA9D-DC0AB7724FFE}.rpt:
Error in formula
'WHILEREADINGRECORDS;
'
What could be the problem. Am I missing something. Am new to Crystal.
Thanks in Advance
SP
prabhu.senthilPosted Jun 23, 2009, 9:39 AM
Thanks for the reply. These reports are designed by developers using CR designer. I guess they use this XSD and XML to design the report. Then they pass it to me. Now I may have to override the connection setting and make it configurable in the app.config in my .net app. My application will be fed with various XML files time to time and I have to bind the data to the report and generate pdf files. So when you say "give the connection from XSD", how to do this on the fly? Hope you understood my question.
Regards
SP
Subramanyam RompicherlaPosted Jun 23, 2009, 9:10 AM
1. in .rpt file you have to give the connection from XSD, in this XSD give the proper elements with datatype those as same in XML file.
2. You written any formula in .rpt. may that formula is wrong. please check it once.
if not, Please let me know