473,473 Members | 1,513 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Export Crystal Report via C#

Hi,

If there is a more appropriate group for this, please point me in the right
direction.

I have a Crystal Report .rpt file that I can get to launch from my code and
I can view it. I pass in parameters to the Viewer and all seems to work
fine. Where it blows up is when I try to export it to a PDF. I've tried
many different combination of examples I've found floating around on the
Internet and all seem to have issues.

The error I'm getting is:
CrystalDecisions.CrystalReport.Engine.ParameterFie ldCurrentValueException:
Missing parameter values.

Am I correct in my assumption that passing parameters to the viewer isn't
the same as passing them to the report and is this the problem?

Below is my code. You can see that I have commented out rpt.ExportToDisk()
in the try block as this didn't work either.

Thanks VERY much in adavance,
John F
-------------------
ReportDocument rpt = new ReportDocument();
ParameterFields paramFields = new ParameterFields ();
ParameterField paramField = new ParameterField ();
ParameterDiscreteValue discreteVal = new ParameterDiscreteValue ();
// Set the name of the parameter field, this must match a
// parameter in the report.
paramField.ParameterFieldName = "year_rpt";

// Set the first discrete value and pass it to the parameter.
discreteVal.Value = "2005";
paramField.CurrentValues.Add (discreteVal);

// Add the parameter to the parameter fields collection.
paramFields.Add (paramField);

// The paramField variable for the seconda parameter
// is set to new so the previous settings will not be overwritten.
paramField = new ParameterField ();

// Set the name of the parameter field, this must match a
// parameter in the report.
paramField.ParameterFieldName = "location";

// Set the second discrete value and pass it to the parameter.
discreteVal = new ParameterDiscreteValue ();
discreteVal.Value = "LPO";
paramField.CurrentValues.Add(discreteVal);

// Add the second parameter to the parameter fields collection.
paramFields.Add (paramField);

// Set the parameter fields collection into the viewer control.
crystalReportViewer1.ParameterFieldInfo = paramFields;
rpt.Load(@"C:\locrvuytddet.rpt");
crystalReportViewer1.ReportSource = rpt;

// Define file name and path.
string filename = "c:\\test.pdf";

try
{

//rpt.ExportToDisk(CrystalDecisions.Shared.ExportFor matType.PortableDocFormat,filename);
DiskFileDestinationOptions diskOpts =
ExportOptions.CreateDiskFileDestinationOptions();
// set export format
ExportOptions exportOpts = new ExportOptions();
exportOpts.ExportFormatType = ExportFormatType.RichText;
exportOpts.ExportDestinationType = ExportDestinationType.DiskFile;

//set the disk file options
diskOpts.DiskFileName = filename;
exportOpts.ExportDestinationOptions = diskOpts;

rpt.Export(exportOpts);

}
catch (Exception err)
{
MessageBox.Show("problems, we have problems! " + err.ToString());
}

Nov 17 '05 #1
0 5043

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Tim Jones | last post by:
Hey all, I am trying to try get a crytal report running properly. A "Hello World" report that does not add criteria to the record selection formula of the report (either in the development tool,...
3
by: Colin Graham | last post by:
Error when attempting to export Crystal Report as PDF document asp.net. I get the following error. Error in File...
6
by: Robin Cushman | last post by:
Hi all, I need some help -- I'm working with an A2K database, using DAO, and am trying to read records into a Crystal Report and then export it to a folder on our network as an Excel...
1
by: John | last post by:
Hi. Sir: Does anyboday know how to export subreport data using the export button in crystal report tool bar? We have a main report including a on-demand report. When we click the on-demand...
0
by: suicidaltendencies | last post by:
I'm able to view the report, but when I click the button on the webpage that shows the report to export into a different format it gives me an error on Export. Any help would be great I keep...
0
by: Leonard Danao | last post by:
Anyone have any ideas as to why this is happenning. There are no other versions of Crystal installed aside from the one that came with vs2003 enterprise. the error happens when the...
1
by: ElanKathir .S.N | last post by:
Hollo Guys, I want to export my crystal reports (Crystal Report 9.0) to word format using visual basic 6.0. Means I want to export the reports with out preview. Now showing report using...
0
by: Henry | last post by:
I have written an ASP/VB.Net application via VS 2003 (Crystal V9) that uses MS Access 2000 as its database. I can export reports that have no linked sub reports for printing. However, I'm unable...
3
by: Brad | last post by:
In a Vista/IIS7 asp.net app, a coded crystal report export is crashing IIS7....but it works just fine in visual studio's cassini web server. And if I create a web form and use the crystal...
3
by: acextreme | last post by:
Hi all, I have a big problem when I try to export from Crystal Report 8.5 in .pdf from VB6. I use a database made in SQL Server 2000. The problem is that all the decimal fields in database are...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.