By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,563 Members | 1,066 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,563 IT Pros & Developers. It's quick & easy.

Crystal 9 Report Viewer & vb.net 2003

P: n/a
This is driving me mad!!

I have a report viewer on a form that is bound to a sql stored
procedure that has one parameter.

I just can't seem to find a way of passing a parameter to the report
viewer, though can make it prompt for the value when refreshing the
report viewer.
-------
CrystalReportViewer1.ReportSource = Application.StartupPath &
"\view_narrative.rpt"

is about as far as I've got - I've looked at the parameterfieldinfo
collection but don't seem to be getting anywhere.

--------

I've no problems with creating a similar report for direct export to
pdf as below:
Dim crparametervalues As ParameterValues
Dim crparameterdiscretevalue As ParameterDiscreteValue
Dim crparameterfielddefinitions As ParameterFieldDefinitions
Dim crparameterfielddefinition As ParameterFieldDefinition

crparameterfielddefinitions =
myreport.DataDefinition.ParameterFields
crparameterfielddefinition =
crparameterfielddefinitions.Item(0)

crparametervalues = crparameterfielddefinition.CurrentValues
crparameterdiscretevalue = New ParameterDiscreteValue
crparameterdiscretevalue.Value = CType(txtRef.Text, Int32)
crparametervalues.Add(crparameterdiscretevalue)

crparameterfielddefinition.ApplyCurrentValues(crpa rametervalues)

Dim myexportoptions As ExportOptions

Dim myexportfile As String

myexportfile = my_full_output_file_string & "-REP-CSE.PDF"
mydiskfiledestinationoptions.DiskFileName = myexportfile
myexportoptions = myreport.ExportOptions

With myexportoptions

..DestinationOptions = mydiskfiledestinationoptions
..ExportDestinationType = .ExportDestinationType.DiskFile
..ExportFormatType = ExportFormatType.PortableDocFormat

End With

myreport.Export() ' as PDF
-------

Anyone have any ideas on this? I'm sure I'm missing something
fundamental somewhere.

JC

Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi JC,

It's easy:
paramField.ParameterFieldName = "firstparam"

paramField2.ParameterFieldName = "secondparam"

discreteVal.Value = "First Parameter"

discreteVal2.Value = "Second Parameter"

paramField.CurrentValues.Add(discreteVal)

paramField2.CurrentValues.Add(discreteVal2)

paramFields.Add(paramField)

paramFields.Add(paramField2)

CrystalReportViewer1.ParameterFieldInfo = paramFields

then run the report

Now of course you could use global variables as well as the literal strings
that I used in the example above.

HTH,

Bernie Yaeger

"JC - home" <jo**@johnclark.me.uk> wrote in message
news:10**********************@f14g2000cwb.googlegr oups.com...
This is driving me mad!!

I have a report viewer on a form that is bound to a sql stored
procedure that has one parameter.

I just can't seem to find a way of passing a parameter to the report
viewer, though can make it prompt for the value when refreshing the
report viewer.
-------
CrystalReportViewer1.ReportSource = Application.StartupPath &
"\view_narrative.rpt"

is about as far as I've got - I've looked at the parameterfieldinfo
collection but don't seem to be getting anywhere.

--------

I've no problems with creating a similar report for direct export to
pdf as below:
Dim crparametervalues As ParameterValues
Dim crparameterdiscretevalue As ParameterDiscreteValue
Dim crparameterfielddefinitions As ParameterFieldDefinitions
Dim crparameterfielddefinition As ParameterFieldDefinition

crparameterfielddefinitions =
myreport.DataDefinition.ParameterFields
crparameterfielddefinition =
crparameterfielddefinitions.Item(0)

crparametervalues = crparameterfielddefinition.CurrentValues
crparameterdiscretevalue = New ParameterDiscreteValue
crparameterdiscretevalue.Value = CType(txtRef.Text, Int32)
crparametervalues.Add(crparameterdiscretevalue)

crparameterfielddefinition.ApplyCurrentValues(crpa rametervalues)

Dim myexportoptions As ExportOptions

Dim myexportfile As String

myexportfile = my_full_output_file_string & "-REP-CSE.PDF"
mydiskfiledestinationoptions.DiskFileName = myexportfile
myexportoptions = myreport.ExportOptions

With myexportoptions

.DestinationOptions = mydiskfiledestinationoptions
.ExportDestinationType = .ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat

End With

myreport.Export() ' as PDF
-------

Anyone have any ideas on this? I'm sure I'm missing something
fundamental somewhere.

JC

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.