Adding Parameters to a report - CR.NET 
Author Message
 Adding Parameters to a report - CR.NET

I have an asp.net page which i want to export a Crystal Report which
requires parameters to pdf. I can get this to work no problem with reports
that dont take any parameters. The problem i have is when the report needs
parameters.

I can display the report on a web form using the CrsytalReportViewerr and
setting the ParameterFieldInfo property as below.
===================================
Dim cr As New Print_rpt()
Dim paramField As New ParameterField()
Dim paramFields As New ParameterFields()
Dim paramDiscreteValue As New ParameterDiscreteValue()
Dim paramValues As New ParameterValues()

paramDiscreteValue.Value = "0000000682"
paramValues.Add(paramDiscreteValue)
paramField.CurrentValues = paramValues
paramFields.Add(paramField)
0
0000682")
CrystalReportViewer1.ParameterFieldInfo = paramFields
CrystalReportViewer1.ReportSource = cr
==========================================

That works no problem. But i dont want to display the report I want to just
export the report. If the report had no parameters I would use the code
below to produce the export.

=============================================================
Dim dfdoCustomers As New
CrystalDecisions.Shared.DiskFileDestinationOptions()
'dfdoCustomers.DiskFileName = "filename.pdf"
Dim cr As New AddressLabels()
'With cr
' .ExportOptions.ExportDestinationType =
CrystalDecisions.Shared.ExportDestinationType.DiskFile
' .ExportOptions.ExportFormatType =
CrystalDecisions.Shared.ExportFormatType.PortableDocFormat
' .ExportOptions.DestinationOptions = dfdoCustomers
' .Export()
'End With
==================================================================

But how would i add parameters to this export code if the report required
parameters. Am i completely on the wrong lines. Do I have to use a
CrsytalReportViewer if i wish to pass parameters to the report?

Thanks in advance. Any help would really be appreciated.

Thanks
Ant



Sun, 13 Nov 2005 06:52:13 GMT  
 Adding Parameters to a report - CR.NET
Set the parameters using the properties of the ReportDocument object and
then call the PrintToPrinter() method (also of the ReportDocument object).
See my free ebook for lots of code.

A Crystal Reports.NET book for programmers? Its free!
* Covers ASP.NET and Windows Forms
* Teaches all phases of report development
* Alerts you to the bugs and how to get around them
* Maps out the complex ReportDocument object model
* Shows how to perform runtime customization
* Demonstrates all options of connecting with ADO.NET
* Gives complete code listings for every concept presented

www.CrystalReportsBook.com?cpgn=ngcr_052703

HTH,

Brian Bischof


Quote:
> I have an asp.net page which i want to export a crystal report which
> requires parameters to pdf. I can get this to work no problem with reports
> that dont take any parameters. The problem i have is when the report needs
> parameters.

> I can display the report on a web form using the CrsytalReportViewerr and
> setting the ParameterFieldInfo property as below.
> ===================================
> Dim cr As New Print_rpt()
> Dim paramField As New ParameterField()
> Dim paramFields As New ParameterFields()
> Dim paramDiscreteValue As New ParameterDiscreteValue()
> Dim paramValues As New ParameterValues()

> paramDiscreteValue.Value = "0000000682"
> paramValues.Add(paramDiscreteValue)
> paramField.CurrentValues = paramValues
> paramFields.Add(paramField)

0

- Show quoted text -

Quote:
> 0000682")
> CrystalReportViewer1.ParameterFieldInfo = paramFields
> CrystalReportViewer1.ReportSource = cr
> ==========================================

> That works no problem. But i dont want to display the report I want to
just
> export the report. If the report had no parameters I would use the code
> below to produce the export.

> =============================================================
> Dim dfdoCustomers As New
> CrystalDecisions.Shared.DiskFileDestinationOptions()
> 'dfdoCustomers.DiskFileName = "filename.pdf"
> Dim cr As New AddressLabels()
> 'With cr
> ' .ExportOptions.ExportDestinationType =
> CrystalDecisions.Shared.ExportDestinationType.DiskFile
> ' .ExportOptions.ExportFormatType =
> CrystalDecisions.Shared.ExportFormatType.PortableDocFormat
> ' .ExportOptions.DestinationOptions = dfdoCustomers
> ' .Export()
> 'End With
> ==================================================================

> But how would i add parameters to this export code if the report required
> parameters. Am i completely on the wrong lines. Do I have to use a
> CrsytalReportViewer if i wish to pass parameters to the report?

> Thanks in advance. Any help would really be appreciated.

> Thanks
> Ant



Sun, 13 Nov 2005 15:08:27 GMT  
 Adding Parameters to a report - CR.NET
Howdy,

In addition to al the great info in Brian's book, there is also a thread on
this in the crystal decisions support forums:
http://support.crystaldecisions.com/forums/message.asp?fid=251&mid=93019

The code there is C#.  There is a thread in
microsoft.public.dotnet.framework.aspnet with VB code. Search for "Missing
Parameter Field Current Value when running a report in .NET -- when
exporting"

HTH,

Sean G.
--
"I'd like to bury my face in two dozen 'Krispy Kreme' glazed donuts & just
lie there & think about Hello Kitty!"

Quote:
> > I have an asp.net page which i want to export a crystal report which
> > requires parameters to pdf. I can get this to work no problem with
reports
> > that dont take any parameters. The problem i have is when the report
needs
> > parameters.



Wed, 16 Nov 2005 00:07:09 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Parameter to Stored Procedure CR 8.5 VB.Net Specified Cast Not Valid

2. CR in VB.NET - Passing Parameters at Runtime

3. preview range parameter in CR.net

4. Parameters to stored proc in CR for .NET

5. CR .net parameter prompting

6. How is field parameter entry supose to take place on cr .net

7. CR 6.0 Report upgraded to CR 7.0 report has formatting issues

8. CR 4.6 - Report doesn't update parameters - HELP

9. CR Print Engine V6 API - Report's parameters

10. parameter query for CR Report Designer Component

11. Displaying Stored Procedure Parameters on CR Report

12. Find good book about using CR.NET with VS.NET and .NET Framework

 

 
Powered by phpBB® Forum Software