468,119 Members | 1,759 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,119 developers. It's quick & easy.

Crystal 9 Report Viewer & vb.net 2003

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
1 1622
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.

Similar topics

1 post views Thread by Stephan | last post: by
2 posts views Thread by Jeannette | last post: by
5 posts views Thread by Robert Schuldenfrei | last post: by
1 post views Thread by Grey | last post: by
3 posts views Thread by Trichy | last post: by
reply views Thread by Chris | last post: by
13 posts views Thread by didacticone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.