473,626 Members | 3,480 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How is it possible ...

....... that nobody knows the answer.
I can't imagine that I am the only one that uses parameters in CR.

So, my question again:

I have the following problem.
(VB.NET 2003 with CR)

I have a report with a multiple-value discrete value and a rangevalue.
The report shows fine in the viewer, but when I hit the export to pdf
button, it only uses one of two discrete values.

This is the code:
Dim BeginPeriode As String
Dim EindPeriode As String

BeginPeriode = Request.QuerySt ring("BeginPeri ode")
EindPeriode = Request.QuerySt ring("EindPerio de")

Dim myReport As New RapportAIRCOSto ringen

Dim paramFields As New ParameterFields
Dim paramField As New ParameterField
Dim discreteVal As New ParameterDiscre teValue
Dim rangeVal As New ParameterRangeV alue

paramField.Para meterFieldName = "FiliaalKeu ze"
discreteVal.Val ue = "2044"
paramField.Curr entValues.Add(d iscreteVal)

discreteVal = New ParameterDiscre teValue
discreteVal.Val ue = "2344"
paramField.Curr entValues.Add(d iscreteVal)

paramFields.Add (paramField)

paramField = New ParameterField

paramField.Para meterFieldName = "Periode"

rangeVal.StartV alue = BeginPeriode
rangeVal.EndVal ue = EindPeriode
paramField.Curr entValues.Add(r angeVal)

paramFields.Add (paramField)

crViewer.Parame terFieldInfo = paramFields
myReport.SetPar ameterValue("Pe riode", rangeVal)
myReport.SetPar ameterValue("Fi liaalKeuze", discreteVal)
crViewer.Report Source = myReport

As you can see I use myReport.SetPar ameterValue to feed the pdf.
It goes wrong with the discrete value. It only sees the second value I
entered and not the first.
How can I get this going?
Kind regards,
Alison


Feb 16 '06 #1
13 2535
Wow, you do all that for Crystal Reports? What is RapportAIRCOSto ringen?
Here is all I do for CR

Dim x As CrystalDecision s.CrystalReport s.Engine.Report Document

x.Load(sReportP ath)
'Reports are not embedded resources
x.SetParameterV alue("Paramater 1", Paramaters(1)) 'Dynamic Paramaters
x.SetParameterV alue("Paramater 2", Paramaters(2))
x.SetDataSource (mydata) 'Strongly
Typed Datasets

Me.CrystalRepor tViewer1.Report Source = x
Me.CrystalRepor tViewer1.PrintR eport()
'Now to answer your question about your code, hmm

Ok, first

Never --> Dim x as new object
'This is silly, lazy and unprofessional. So if you are in high
school, keep the course.
Instead --> Dim x as object
Set x = new object
'Reserve your space and contract
'Then make use of it.

I think this is your problem

myReport.SetPar ameterValue("Fi liaalKeuze", discreteVal)

Why are you setting the crView paramaters and the myReport paramaters?
-->crViewer.Param eterFieldInfo = paramFields
-->myReport.SetPa rameterValue("P eriode", rangeVal)

I think that myReport is the only think that needs to be set
I had to spent time reading your code to understand what you were doing.

Here is an attempt to clean it up.

Private Sub TestIT()

Dim myReport As RapportAIRCOSto ringen
Dim paramFields As ParameterFields
Dim paramField As ParameterField

Dim BeginPeriode As String
Dim EindPeriode As String

'Todo wrap everything in try
paramFields = New ParameterFields

Try
BeginPeriode = Request.QuerySt ring("BeginPeri ode")
EindPeriode = Request.QuerySt ring("EindPerio de")
Catch ex As Exception
Dim exCustom As ApplicationExce ption
exCustom = New ApplicationExce ption("Unable to parse Query
Paramaters.", ex)
Throw exCustom
End Try

'Todo wrap in try
paramField = CreateParamater ("FiliaalKeuze" )
paramField.Curr entValues.Add(C reateParameterD iscreteValue(20 44))
paramField.Curr entValues.Add(C reateParameterD iscreteValue(23 44))
myReport.SetPar ameterValue("Fi liaalKeuze", paramField)
'paramFields.Ad d(paramField) --> Not needed

'Todo wrap in try
paramField = CreateParamater ("Periode")
paramField.Curr entValues.Add(C reateParameterR angeValue(Begin Periode,
EindPeriode))
myReport.SetPar ameterValue("Pe riode", paramField)
'paramFields.Ad d(paramField)--> Not needed

'Todo wrap in try, i don't think you need this
'myReport.SetPa rameterValue("P eriode", rangeVal)
'myReport.SetPa rameterValue("F iliaalKeuze", discreteVal)

'Todo, determine if we need this step; I don't think you do
'crViewer.Param eterFieldInfo = paramFields

crViewer.Report Source = myReport

End Sub

Private Function CreateParamater (ByVal ParamaterName As String) As
ParameterField
Dim paramField As ParameterField

paramField = New ParameterField
paramField.Para meterFieldName = ParamaterName

Return paramField

End Function

Private Function CreateParameter DiscreteValue(B yVal Value As Object) As
ParameterDiscre teValue

Dim paramDiscreteVa lue As ParameterDiscre teValue
paramDiscreteVa lue = New ParameterDiscre teValue
paramDiscreteVa lue = Value

Return paramDiscreteVa lue

End Function

Private Function CreateParameter RangeValue(ByVa l StartRange As Object,
ByVal EndRange As Object) As ParameterRangeV alue
Dim paramRangeValue As ParameterRangeV alue

paramRangeValue = New ParameterRangeV alue

paramRangeValue .StartValue = StartRange
paramRangeValue .EndValue = EndRange

Return paramRangeValue
End Function

"Alison Givens" <in**@cross-it.nl> wrote in message
news:eW******** *****@TK2MSFTNG P11.phx.gbl...
...... that nobody knows the answer.
I can't imagine that I am the only one that uses parameters in CR.

So, my question again:

I have the following problem.
(VB.NET 2003 with CR)

I have a report with a multiple-value discrete value and a rangevalue.
The report shows fine in the viewer, but when I hit the export to pdf
button, it only uses one of two discrete values.

This is the code:
Dim BeginPeriode As String
Dim EindPeriode As String

BeginPeriode = Request.QuerySt ring("BeginPeri ode")
EindPeriode = Request.QuerySt ring("EindPerio de")

Dim myReport As New RapportAIRCOSto ringen

Dim paramFields As New ParameterFields
Dim paramField As New ParameterField
Dim discreteVal As New ParameterDiscre teValue
Dim rangeVal As New ParameterRangeV alue

paramField.Para meterFieldName = "FiliaalKeu ze"
discreteVal.Val ue = "2044"
paramField.Curr entValues.Add(d iscreteVal)

discreteVal = New ParameterDiscre teValue
discreteVal.Val ue = "2344"
paramField.Curr entValues.Add(d iscreteVal)

paramFields.Add (paramField)

paramField = New ParameterField

paramField.Para meterFieldName = "Periode"

rangeVal.StartV alue = BeginPeriode
rangeVal.EndVal ue = EindPeriode
paramField.Curr entValues.Add(r angeVal)

paramFields.Add (paramField)

crViewer.Parame terFieldInfo = paramFields
myReport.SetPar ameterValue("Pe riode", rangeVal)
myReport.SetPar ameterValue("Fi liaalKeuze", discreteVal)
crViewer.Report Source = myReport

As you can see I use myReport.SetPar ameterValue to feed the pdf.
It goes wrong with the discrete value. It only sees the second value I
entered and not the first.
How can I get this going?
Kind regards,
Alison

Feb 16 '06 #2
When I use your solution I get blue lines under the text like this

paramField = CreateParamater ("FiliaalKeuze" )
The text is:
Value of type '1 dimensional array of
CrystalDecision s.Shared.Parame terField' cannot be converted
to 'Crystal.Decisi ons.Shared.Para meterField'

Return paramField
The text is:
Value of type 'CrystalDecisio ns.Shared.Param eterField' cannot be converted
to '1 dimensional array of Crystal.Decisio ns.Shared.Param eterField'

Same for
paramField = CreateParamater ("Periode")
Return paramDiscreteVa lue

Any idea what causes this?

Alison
"AMDRIT" <am****@hotmail .com> wrote in message
news:ur******** *****@TK2MSFTNG P14.phx.gbl...
Wow, you do all that for Crystal Reports? What is RapportAIRCOSto ringen?
Here is all I do for CR

Dim x As CrystalDecision s.CrystalReport s.Engine.Report Document

x.Load(sReportP ath) 'Reports are not embedded resources
x.SetParameterV alue("Paramater 1", Paramaters(1)) 'Dynamic Paramaters
x.SetParameterV alue("Paramater 2", Paramaters(2))
x.SetDataSource (mydata)
'Strongly Typed Datasets

Me.CrystalRepor tViewer1.Report Source = x
Me.CrystalRepor tViewer1.PrintR eport()
'Now to answer your question about your code, hmm

Ok, first

Never --> Dim x as new object
'This is silly, lazy and unprofessional. So if you are in high
school, keep the course.
Instead --> Dim x as object
Set x = new object
'Reserve your space and contract
'Then make use of it.

I think this is your problem

myReport.SetPar ameterValue("Fi liaalKeuze", discreteVal)

Why are you setting the crView paramaters and the myReport paramaters?
-->crViewer.Param eterFieldInfo = paramFields
-->myReport.SetPa rameterValue("P eriode", rangeVal)

I think that myReport is the only think that needs to be set
I had to spent time reading your code to understand what you were doing.

Here is an attempt to clean it up.

Private Sub TestIT()

Dim myReport As RapportAIRCOSto ringen
Dim paramFields As ParameterFields
Dim paramField As ParameterField

Dim BeginPeriode As String
Dim EindPeriode As String

'Todo wrap everything in try
paramFields = New ParameterFields

Try
BeginPeriode = Request.QuerySt ring("BeginPeri ode")
EindPeriode = Request.QuerySt ring("EindPerio de")
Catch ex As Exception
Dim exCustom As ApplicationExce ption
exCustom = New ApplicationExce ption("Unable to parse Query
Paramaters.", ex)
Throw exCustom
End Try

'Todo wrap in try
paramField = CreateParamater ("FiliaalKeuze" )
paramField.Curr entValues.Add(C reateParameterD iscreteValue(20 44))
paramField.Curr entValues.Add(C reateParameterD iscreteValue(23 44))
myReport.SetPar ameterValue("Fi liaalKeuze", paramField)
'paramFields.Ad d(paramField) --> Not needed

'Todo wrap in try
paramField = CreateParamater ("Periode")
paramField.Curr entValues.Add(C reateParameterR angeValue(Begin Periode,
EindPeriode))
myReport.SetPar ameterValue("Pe riode", paramField)
'paramFields.Ad d(paramField)--> Not needed

'Todo wrap in try, i don't think you need this
'myReport.SetPa rameterValue("P eriode", rangeVal)
'myReport.SetPa rameterValue("F iliaalKeuze", discreteVal)

'Todo, determine if we need this step; I don't think you do
'crViewer.Param eterFieldInfo = paramFields

crViewer.Report Source = myReport

End Sub

Private Function CreateParamater (ByVal ParamaterName As String) As
ParameterField
Dim paramField As ParameterField

paramField = New ParameterField
paramField.Para meterFieldName = ParamaterName

Return paramField

End Function

Private Function CreateParameter DiscreteValue(B yVal Value As Object) As
ParameterDiscre teValue

Dim paramDiscreteVa lue As ParameterDiscre teValue
paramDiscreteVa lue = New ParameterDiscre teValue
paramDiscreteVa lue = Value

Return paramDiscreteVa lue

End Function

Private Function CreateParameter RangeValue(ByVa l StartRange As Object,
ByVal EndRange As Object) As ParameterRangeV alue
Dim paramRangeValue As ParameterRangeV alue

paramRangeValue = New ParameterRangeV alue

paramRangeValue .StartValue = StartRange
paramRangeValue .EndValue = EndRange

Return paramRangeValue
End Function

"Alison Givens" <in**@cross-it.nl> wrote in message
news:eW******** *****@TK2MSFTNG P11.phx.gbl...
...... that nobody knows the answer.
I can't imagine that I am the only one that uses parameters in CR.

So, my question again:

I have the following problem.
(VB.NET 2003 with CR)

I have a report with a multiple-value discrete value and a rangevalue.
The report shows fine in the viewer, but when I hit the export to pdf
button, it only uses one of two discrete values.

This is the code:
Dim BeginPeriode As String
Dim EindPeriode As String

BeginPeriode = Request.QuerySt ring("BeginPeri ode")
EindPeriode = Request.QuerySt ring("EindPerio de")

Dim myReport As New RapportAIRCOSto ringen

Dim paramFields As New ParameterFields
Dim paramField As New ParameterField
Dim discreteVal As New ParameterDiscre teValue
Dim rangeVal As New ParameterRangeV alue

paramField.Para meterFieldName = "FiliaalKeu ze"
discreteVal.Val ue = "2044"
paramField.Curr entValues.Add(d iscreteVal)

discreteVal = New ParameterDiscre teValue
discreteVal.Val ue = "2344"
paramField.Curr entValues.Add(d iscreteVal)

paramFields.Add (paramField)

paramField = New ParameterField

paramField.Para meterFieldName = "Periode"

rangeVal.StartV alue = BeginPeriode
rangeVal.EndVal ue = EindPeriode
paramField.Curr entValues.Add(r angeVal)

paramFields.Add (paramField)

crViewer.Parame terFieldInfo = paramFields
myReport.SetPar ameterValue("Pe riode", rangeVal)
myReport.SetPar ameterValue("Fi liaalKeuze", discreteVal)
crViewer.Report Source = myReport

As you can see I use myReport.SetPar ameterValue to feed the pdf.
It goes wrong with the discrete value. It only sees the second value I
entered and not the first.
How can I get this going?
Kind regards,
Alison


Feb 20 '06 #3
All I did was take your code and break it up. I haven't tested the code,
rather; I was just breaking up your code for readability.

You had:

Dim paramField As New ParameterField
paramField = New ParameterField
paramField.Para meterFieldName = "Periode"

I changed to (I don't see a difference):

paramField = CreateParamater ("Periode")

Private Function CreateParamater (ByVal ParamaterName As String) As
ParameterField
Dim paramField As ParameterField

paramField = New ParameterField
paramField.Para meterFieldName = ParamaterName

Return paramField

End Function

Perhaps you could share your resulting code for comparison? Did you see
that I suggested the error in your code was

myReport.SetPar ameterValue("Fi liaalKeuze", discreteVal) 'You only call this
statement once (Effectively 2344) but you wanted two values.
"Alison Givens" <in**@cross-it.nl> wrote in message
news:ee******** ******@TK2MSFTN GP09.phx.gbl...
When I use your solution I get blue lines under the text like this

paramField = CreateParamater ("FiliaalKeuze" )
The text is:
Value of type '1 dimensional array of
CrystalDecision s.Shared.Parame terField' cannot be converted
to 'Crystal.Decisi ons.Shared.Para meterField'

Return paramField
The text is:
Value of type 'CrystalDecisio ns.Shared.Param eterField' cannot be converted
to '1 dimensional array of Crystal.Decisio ns.Shared.Param eterField'

Same for
paramField = CreateParamater ("Periode")
Return paramDiscreteVa lue

Any idea what causes this?

Alison
"AMDRIT" <am****@hotmail .com> wrote in message
news:ur******** *****@TK2MSFTNG P14.phx.gbl...
Wow, you do all that for Crystal Reports? What is RapportAIRCOSto ringen?
Here is all I do for CR

Dim x As CrystalDecision s.CrystalReport s.Engine.Report Document

x.Load(sReportP ath) 'Reports are not embedded resources
x.SetParameterV alue("Paramater 1", Paramaters(1)) 'Dynamic Paramaters
x.SetParameterV alue("Paramater 2", Paramaters(2))
x.SetDataSource (mydata) 'Strongly Typed Datasets

Me.CrystalRepor tViewer1.Report Source = x
Me.CrystalRepor tViewer1.PrintR eport()
'Now to answer your question about your code, hmm

Ok, first

Never --> Dim x as new object
'This is silly, lazy and unprofessional. So if you are in high
school, keep the course.
Instead --> Dim x as object
Set x = new object
'Reserve your space and contract
'Then make use of it.

I think this is your problem

myReport.SetPar ameterValue("Fi liaalKeuze", discreteVal)

Why are you setting the crView paramaters and the myReport paramaters?
-->crViewer.Param eterFieldInfo = paramFields
-->myReport.SetPa rameterValue("P eriode", rangeVal)

I think that myReport is the only think that needs to be set
I had to spent time reading your code to understand what you were doing.

Here is an attempt to clean it up.

Private Sub TestIT()

Dim myReport As RapportAIRCOSto ringen
Dim paramFields As ParameterFields
Dim paramField As ParameterField

Dim BeginPeriode As String
Dim EindPeriode As String

'Todo wrap everything in try
paramFields = New ParameterFields

Try
BeginPeriode = Request.QuerySt ring("BeginPeri ode")
EindPeriode = Request.QuerySt ring("EindPerio de")
Catch ex As Exception
Dim exCustom As ApplicationExce ption
exCustom = New ApplicationExce ption("Unable to parse Query
Paramaters.", ex)
Throw exCustom
End Try

'Todo wrap in try
paramField = CreateParamater ("FiliaalKeuze" )
paramField.Curr entValues.Add(C reateParameterD iscreteValue(20 44))
paramField.Curr entValues.Add(C reateParameterD iscreteValue(23 44))
myReport.SetPar ameterValue("Fi liaalKeuze", paramField)
'paramFields.Ad d(paramField) --> Not needed

'Todo wrap in try
paramField = CreateParamater ("Periode")
paramField.Curr entValues.Add(C reateParameterR angeValue(Begin Periode,
EindPeriode))
myReport.SetPar ameterValue("Pe riode", paramField)
'paramFields.Ad d(paramField)--> Not needed

'Todo wrap in try, i don't think you need this
'myReport.SetPa rameterValue("P eriode", rangeVal)
'myReport.SetPa rameterValue("F iliaalKeuze", discreteVal)

'Todo, determine if we need this step; I don't think you do
'crViewer.Param eterFieldInfo = paramFields

crViewer.Report Source = myReport

End Sub

Private Function CreateParamater (ByVal ParamaterName As String) As
ParameterField
Dim paramField As ParameterField

paramField = New ParameterField
paramField.Para meterFieldName = ParamaterName

Return paramField

End Function

Private Function CreateParameter DiscreteValue(B yVal Value As Object) As
ParameterDiscre teValue

Dim paramDiscreteVa lue As ParameterDiscre teValue
paramDiscreteVa lue = New ParameterDiscre teValue
paramDiscreteVa lue = Value

Return paramDiscreteVa lue

End Function

Private Function CreateParameter RangeValue(ByVa l StartRange As Object,
ByVal EndRange As Object) As ParameterRangeV alue
Dim paramRangeValue As ParameterRangeV alue

paramRangeValue = New ParameterRangeV alue

paramRangeValue .StartValue = StartRange
paramRangeValue .EndValue = EndRange

Return paramRangeValue
End Function

"Alison Givens" <in**@cross-it.nl> wrote in message
news:eW******** *****@TK2MSFTNG P11.phx.gbl...
...... that nobody knows the answer.
I can't imagine that I am the only one that uses parameters in CR.

So, my question again:

I have the following problem.
(VB.NET 2003 with CR)

I have a report with a multiple-value discrete value and a rangevalue.
The report shows fine in the viewer, but when I hit the export to pdf
button, it only uses one of two discrete values.

This is the code:
Dim BeginPeriode As String
Dim EindPeriode As String

BeginPeriode = Request.QuerySt ring("BeginPeri ode")
EindPeriode = Request.QuerySt ring("EindPerio de")

Dim myReport As New RapportAIRCOSto ringen

Dim paramFields As New ParameterFields
Dim paramField As New ParameterField
Dim discreteVal As New ParameterDiscre teValue
Dim rangeVal As New ParameterRangeV alue

paramField.Para meterFieldName = "FiliaalKeu ze"
discreteVal.Val ue = "2044"
paramField.Curr entValues.Add(d iscreteVal)

discreteVal = New ParameterDiscre teValue
discreteVal.Val ue = "2344"
paramField.Curr entValues.Add(d iscreteVal)

paramFields.Add (paramField)

paramField = New ParameterField

paramField.Para meterFieldName = "Periode"

rangeVal.StartV alue = BeginPeriode
rangeVal.EndVal ue = EindPeriode
paramField.Curr entValues.Add(r angeVal)

paramFields.Add (paramField)

crViewer.Parame terFieldInfo = paramFields
myReport.SetPar ameterValue("Pe riode", rangeVal)
myReport.SetPar ameterValue("Fi liaalKeuze", discreteVal)
crViewer.Report Source = myReport

As you can see I use myReport.SetPar ameterValue to feed the pdf.
It goes wrong with the discrete value. It only sees the second value I
entered and not the first.
How can I get this going?
Kind regards,
Alison



Feb 20 '06 #4
> Perhaps you could share your resulting code for comparison? Did you see
that I suggested the error in your code was

myReport.SetPar ameterValue("Fi liaalKeuze", discreteVal) 'You only call
this statement once (Effectively 2344) but you wanted two values.
To get the thing going, it would be enough for me at first to know how to
call the statement twice, so the other value is forwarded too.
(btw, these two values will be SessionObjects two, but I did it hardcoded
for testing)
Best would be ofcourse that I learn to do it 'clean' of course. I am a real
newbee at this.

Here is the rest of my code:

Imports CrystalDecision s.CrystalReport s.Engine
Imports CrystalDecision s.CrystalReport s.Engine.Report Document
Imports CrystalDecision s.Shared
Imports System.IO
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()

Dim myReport As RapportAIRCOSto ringen
Dim paramFields As ParameterFields
Dim paramField As ParameterField

Dim BeginPeriode As String
Dim EindPeriode As String

'Todo wrap everything in try
paramFields = New ParameterFields

Try
BeginPeriode = Request.QuerySt ring("BeginPeri ode")
EindPeriode = Request.QuerySt ring("EindPerio de")
Catch ex As Exception
Dim exCustom As ApplicationExce ption
exCustom = New ApplicationExce ption("Unable to parse Query
Paramaters.", ex)
Throw exCustom
End Try

'Todo wrap in try
paramField = CreateParameter ("FiliaalKeuze" )
paramField.Curr entValues.Add(C reateParameterD iscreteValue(20 44))
paramField.Curr entValues.Add(C reateParameterD iscreteValue(23 44))
myReport.SetPar ameterValue("Fi liaalKeuze", paramField)
'Todo wrap in try
paramField = CreateParameter ("Periode")
paramField.Curr entValues.Add(C reateParameterR angeValue(Begin Periode,
EindPeriode))
myReport.SetPar ameterValue("Pe riode", paramField)
crViewer.Report Source = myReport
'exporteren to pdf
Dim myExportOptions As CrystalDecision s.Shared.Export Options
Dim myDiskFileDesti nationOptions As
CrystalDecision s.Shared.DiskFi leDestinationOp tions
Dim myExportFile As String

myExportFile = "\\192.168.2.10 6\syn2sql$\PDF_ " &
Session.Session ID.ToString & ".pdf"
myDiskFileDesti nationOptions = New
CrystalDecision s.Shared.DiskFi leDestinationOp tions
myDiskFileDesti nationOptions.D iskFileName = myExportFile
myExportOptions = myReport.Export Options
With myExportOptions
.DestinationOpt ions = myDiskFileDesti nationOptions
.ExportDestinat ionType = .ExportDestinat ionType.DiskFil e
.ExportFormatTy pe = .ExportFormatTy pe.PortableDocF ormat
End With

Try
myReport.Export ()
Catch err As Exception
Response.Write( "<BR>")
Response.Write( err.Message.ToS tring)
End Try

Session("export bestand") = myExportFile
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
Private Sub cmdPrint_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdPrint.Click
Response.ClearC ontent()
Response.ClearH eaders()
Response.Conten tType = "applicatio n/pdf"
Dim myExportFile As String = CType(Session.I tem("exportbest and"),
String)

Response.WriteF ile(myExportFil e)
Response.Flush( )
Response.Close( )

System.IO.File. Delete(myExport File)
End Sub

Private Function CreateParameter (ByVal ParameterName As String) As
ParameterField( )
Dim paramField As ParameterField

paramField = New ParameterField
paramField.Para meterFieldName = ParameterName

'Return paramField

End Function

Private Function CreateParameter DiscreteValue(B yVal Value As Object) As
ParameterDiscre teValue()

Dim paramDiscreteVa lue As ParameterDiscre teValue
paramDiscreteVa lue = New ParameterDiscre teValue
paramDiscreteVa lue = Value

'Return paramDiscreteVa lue

End Function

Private Function CreateParameter RangeValue(ByVa l StartRange As Object,
ByVal EndRange As Object) As ParameterRangeV alue
Dim paramRangeValue As ParameterRangeV alue

paramRangeValue = New ParameterRangeV alue

paramRangeValue .StartValue = StartRange
paramRangeValue .EndValue = EndRange

Return paramRangeValue
End Function
Private Sub cmdEerste_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdEerste.Click
crViewer.ShowFi rstPage()
End Sub

Private Sub cmdLaatste_Clic k(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdLaatste.Clic k
crViewer.ShowLa stPage()
End Sub

Private Sub cmdTerug_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdTerug.Click
crViewer.ShowPr eviousPage()
End Sub

Private Sub cmdVerder_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdVerder.Click
crViewer.ShowNe xtPage()
End Sub

Private Sub drpZoom_Selecte dIndexChanged(B yVal sender As Object, ByVal e
As System.EventArg s) Handles drpZoom.Selecte dIndexChanged
crViewer.Zoom(d rpZoom.Selected Item.Value)
End Sub
Private Sub Page_Unload(ByV al sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Unload
Dim myExportFile As String = CType(Session.I tem("exportbest and"),
String)

System.IO.File. Delete(myExport File)
End Sub
End Class


"Alison Givens" <in**@cross-it.nl> wrote in message
news:ee******** ******@TK2MSFTN GP09.phx.gbl...
When I use your solution I get blue lines under the text like this

paramField = CreateParamater ("FiliaalKeuze" )
The text is:
Value of type '1 dimensional array of
CrystalDecision s.Shared.Parame terField' cannot be converted
to 'Crystal.Decisi ons.Shared.Para meterField'

Return paramField
The text is:
Value of type 'CrystalDecisio ns.Shared.Param eterField' cannot be
converted
to '1 dimensional array of Crystal.Decisio ns.Shared.Param eterField'

Same for
paramField = CreateParamater ("Periode")
Return paramDiscreteVa lue

Any idea what causes this?

Alison
"AMDRIT" <am****@hotmail .com> wrote in message
news:ur******** *****@TK2MSFTNG P14.phx.gbl...
Wow, you do all that for Crystal Reports? What is
RapportAIRCOSto ringen?
Here is all I do for CR

Dim x As CrystalDecision s.CrystalReport s.Engine.Report Document

x.Load(sReportP ath) 'Reports are not embedded resources
x.SetParameterV alue("Paramater 1", Paramaters(1)) 'Dynamic
Paramaters
x.SetParameterV alue("Paramater 2", Paramaters(2))
x.SetDataSource (mydata) 'Strongly Typed Datasets

Me.CrystalRepor tViewer1.Report Source = x
Me.CrystalRepor tViewer1.PrintR eport()
'Now to answer your question about your code, hmm

Ok, first

Never --> Dim x as new object
'This is silly, lazy and unprofessional. So if you are in high
school, keep the course.
Instead --> Dim x as object
Set x = new object
'Reserve your space and contract
'Then make use of it.

I think this is your problem

myReport.SetPar ameterValue("Fi liaalKeuze", discreteVal)

Why are you setting the crView paramaters and the myReport paramaters?
-->crViewer.Param eterFieldInfo = paramFields
-->myReport.SetPa rameterValue("P eriode", rangeVal)

I think that myReport is the only think that needs to be set
I had to spent time reading your code to understand what you were doing.

Here is an attempt to clean it up.

Private Sub TestIT()

Dim myReport As RapportAIRCOSto ringen
Dim paramFields As ParameterFields
Dim paramField As ParameterField

Dim BeginPeriode As String
Dim EindPeriode As String

'Todo wrap everything in try
paramFields = New ParameterFields

Try
BeginPeriode = Request.QuerySt ring("BeginPeri ode")
EindPeriode = Request.QuerySt ring("EindPerio de")
Catch ex As Exception
Dim exCustom As ApplicationExce ption
exCustom = New ApplicationExce ption("Unable to parse Query
Paramaters.", ex)
Throw exCustom
End Try

'Todo wrap in try
paramField = CreateParamater ("FiliaalKeuze" )
paramField.Curr entValues.Add(C reateParameterD iscreteValue(20 44))
paramField.Curr entValues.Add(C reateParameterD iscreteValue(23 44))
myReport.SetPar ameterValue("Fi liaalKeuze", paramField)
'paramFields.Ad d(paramField) --> Not needed

'Todo wrap in try
paramField = CreateParamater ("Periode")
paramField.Curr entValues.Add(C reateParameterR angeValue(Begin Periode,
EindPeriode))
myReport.SetPar ameterValue("Pe riode", paramField)
'paramFields.Ad d(paramField)--> Not needed

'Todo wrap in try, i don't think you need this
'myReport.SetPa rameterValue("P eriode", rangeVal)
'myReport.SetPa rameterValue("F iliaalKeuze", discreteVal)

'Todo, determine if we need this step; I don't think you do
'crViewer.Param eterFieldInfo = paramFields

crViewer.Report Source = myReport

End Sub

Private Function CreateParamater (ByVal ParamaterName As String) As
ParameterField
Dim paramField As ParameterField

paramField = New ParameterField
paramField.Para meterFieldName = ParamaterName

Return paramField

End Function

Private Function CreateParameter DiscreteValue(B yVal Value As Object) As
ParameterDiscre teValue

Dim paramDiscreteVa lue As ParameterDiscre teValue
paramDiscreteVa lue = New ParameterDiscre teValue
paramDiscreteVa lue = Value

Return paramDiscreteVa lue

End Function

Private Function CreateParameter RangeValue(ByVa l StartRange As Object,
ByVal EndRange As Object) As ParameterRangeV alue
Dim paramRangeValue As ParameterRangeV alue

paramRangeValue = New ParameterRangeV alue

paramRangeValue .StartValue = StartRange
paramRangeValue .EndValue = EndRange

Return paramRangeValue
End Function

"Alison Givens" <in**@cross-it.nl> wrote in message
news:eW******** *****@TK2MSFTNG P11.phx.gbl...
...... that nobody knows the answer.
I can't imagine that I am the only one that uses parameters in CR.

So, my question again:

I have the following problem.
(VB.NET 2003 with CR)

I have a report with a multiple-value discrete value and a rangevalue.
The report shows fine in the viewer, but when I hit the export to pdf
button, it only uses one of two discrete values.

This is the code:
Dim BeginPeriode As String
Dim EindPeriode As String

BeginPeriode = Request.QuerySt ring("BeginPeri ode")
EindPeriode = Request.QuerySt ring("EindPerio de")

Dim myReport As New RapportAIRCOSto ringen

Dim paramFields As New ParameterFields
Dim paramField As New ParameterField
Dim discreteVal As New ParameterDiscre teValue
Dim rangeVal As New ParameterRangeV alue

paramField.Para meterFieldName = "FiliaalKeu ze"
discreteVal.Val ue = "2044"
paramField.Curr entValues.Add(d iscreteVal)

discreteVal = New ParameterDiscre teValue
discreteVal.Val ue = "2344"
paramField.Curr entValues.Add(d iscreteVal)

paramFields.Add (paramField)

paramField = New ParameterField

paramField.Para meterFieldName = "Periode"

rangeVal.StartV alue = BeginPeriode
rangeVal.EndVal ue = EindPeriode
paramField.Curr entValues.Add(r angeVal)

paramFields.Add (paramField)

crViewer.Parame terFieldInfo = paramFields
myReport.SetPar ameterValue("Pe riode", rangeVal)
myReport.SetPar ameterValue("Fi liaalKeuze", discreteVal)
crViewer.Report Source = myReport

As you can see I use myReport.SetPar ameterValue to feed the pdf.
It goes wrong with the discrete value. It only sees the second value I
entered and not the first.
How can I get this going?
Kind regards,
Alison




Feb 20 '06 #5
Ok, first the isue you were having with the "Blue lines" is:

Private Function CreateParameter DiscreteValue(B yVal Value As Object) As
ParameterDiscre teValue()
--> Retun type is expecting an array of ParameterDiscre teValue

it should be

Private Function CreateParameter DiscreteValue(B yVal Value As Object) As
ParameterDiscre teValue
--> Retun type is expecting an single ParameterDiscre teValue

Second (Mostly because I was bored and also because I am still a novice), I
have altered your code yet again.
Private Enum FileNameFormats
SessionID = 0
GUIDDashes = 1
GUIDNoDashes = 2
End Enum

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()

Dim myReport As RapportAIRCOSto ringen
Dim myExportOptions As CrystalDecision s.Shared.Export Options

Try

Try
PrepareReport(m yReport)
Catch ex As Exception
Dim exc As ApplicationExce ption
exc = New ApplicationExce ption("Unable to prepare report.", ex)
Throw exc
End Try

Try
'exporteren to pdf
myExportOptions = GetExportOption s(FileNameForma ts.GUIDNoDashes ,
CType(myReport,
CrystalDecision s.CrystalReport s.Engine.Report Document).Expor tOptions)
myReport.Export ()

Catch ex As Exception
Dim exc As ApplicationExce ption
exc = New ApplicationExce ption("Unable to export report.", ex)
Throw exc
End Try

crViewer.Report Source = myReport

Session("export bestand") = CType(myExportO ptions.Destinat ionOptions,
CrystalDecision s.Shared.DiskFi leDestinationOp tions).DiskFile Name

Catch err As Exception
Response.Write( "<BR>")
Response.Write( err.Message.ToS tring)
End Try

End Sub

#Region "Page Implementation"

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Private Sub Page_Unload(ByV al sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Unload
Dim myExportFile As String = CType(Session.I tem("exportbest and"),
String)

System.IO.File. Delete(myExport File)
End Sub

#End Region

#Region "Report Setup"

Private Sub PrepareReport(B yVal myReport As
CrystalDecision s.CrystalReport s.Engine.Report Document)

Dim paramFields As ParameterFields
Dim paramField As ParameterField

Const SessionExecptio n As String = "Unable to read session objects."

Try

paramFields = New ParameterFields
Try
paramField = CreateParameter ("FiliaalKeuze" )
paramField.Curr entValues.Add(C reateParameterD iscreteValue(Ge tSessionValue(" DiscreteValue1" )))
paramField.Curr entValues.Add(C reateParameterD iscreteValue(Ge tSessionValue(" DiscreteValue1" )))
Catch ex As Exception
Dim exc As System.Applicat ionException
exc = New System.Applicat ionException(Se ssionExecption, ex)
Throw exc
End Try

myReport.SetPar ameterValue("Fi liaalKeuze", paramField)

Try
'Todo wrap in try
paramField = CreateParameter ("Periode")
paramField.Curr entValues.Add(C reateParameterR angeValue(GetSe ssionValue("Beg inPeriode"),
GetSessionValue ("EindPeriode") ))
Catch ex As Exception
Dim exc As System.Applicat ionException
exc = New System.Applicat ionException(Se ssionExecption, ex)
Throw exc
End Try

myReport.SetPar ameterValue("Pe riode", paramField)

Catch ex As Exception

Dim exc As System.Applicat ionException
exc = New System.Applicat ionException("U nable to set paramater
value.", ex)
Throw exc

End Try
End Sub

Private Function CreateParameter (ByVal ParameterName As String) As
ParameterField
Dim paramField As ParameterField

paramField = New ParameterField
paramField.Para meterFieldName = ParameterName

Return paramField

End Function

Private Function CreateParameter DiscreteValue(B yVal Value As Object) As
ParameterDiscre teValue()

Dim paramDiscreteVa lue As ParameterDiscre teValue
paramDiscreteVa lue = New ParameterDiscre teValue
paramDiscreteVa lue = Value

'Return paramDiscreteVa lue

End Function

Private Function CreateParameter RangeValue(ByVa l StartRange As Object,
ByVal EndRange As Object) As ParameterRangeV alue
Dim paramRangeValue As ParameterRangeV alue

paramRangeValue = New ParameterRangeV alue

paramRangeValue .StartValue = StartRange
paramRangeValue .EndValue = EndRange

Return paramRangeValue
End Function

#End Region

#Region "Report Export"

Private Function GetExportOption s(ByVal UniqueFormat As FileNameFormats ,
ByVal ExportOptions As CrystalDecision s.Shared.Export Options) As
CrystalDecision s.Shared.Export Options

Dim myExportFile As String
Dim myExportOptions As CrystalDecision s.Shared.Export Options
Dim myDiskFileDesti nationOptions As
CrystalDecision s.Shared.DiskFi leDestinationOp tions

Try

Select Case UniqueFormat
Case FileNameFormats .SessionID
myExportFile = Session.Session ID.ToString
Case FileNameFormats .GUIDDashes
myExportFile = System.Guid.New Guid.ToString(" D")
Case FileNameFormats .GUIDNoDashes
myExportFile = System.Guid.New Guid.ToString(" N")
End Select

myExportFile = System.IO.Path. Combine(GetExpo rtRoot,
String.Format(" PDF_{0}.pdf", myExportFile))

myDiskFileDesti nationOptions = New
CrystalDecision s.Shared.DiskFi leDestinationOp tions
myDiskFileDesti nationOptions.D iskFileName = myExportFile

myExportOptions = ExportOptions

With myExportOptions
.DestinationOpt ions = myDiskFileDesti nationOptions
.ExportDestinat ionType = .ExportDestinat ionType.DiskFil e
.ExportFormatTy pe = .ExportFormatTy pe.PortableDocF ormat
End With

Catch ex As Exception

Dim exc As System.Applicat ionException
exc = New System.Applicat ionException("U nable to prepare export
options.", ex)
Throw exc

End Try

Return myExportOptions

End Function

Private Function GetExportRoot(B yVal FromApplication As Boolean) As String

Dim strExportRoot As String

If FromApplication Then
Try
Application.loc k()
strExportRoot = Application("Re portExportRoot" )
Catch ex As Exception
Dim exc As ApplicationExce ption
exc = New ApplicationExce ption("Unable to lock Web Application for
read.", ex)
Throw exc
Finally
Application.unl ock()
End Try
Else
strExportRoot = Session("Report ExportRoot")
End If

Return strExportRoot

End Function

#End Region

#Region "Navigation Implementation"

Private Sub cmdPrint_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdPrint.Click

Response.ClearC ontent()
Response.ClearH eaders()
Response.Conten tType = "applicatio n/pdf"

Dim myExportFile As String = CType(Session.I tem("exportbest and"),
String)

Response.WriteF ile(myExportFil e)
Response.Flush( )
Response.Close( )

System.IO.File. Delete(myExport File)

End Sub

Private Sub cmdEerste_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdEerste.Click
crViewer.ShowFi rstPage()
End Sub

Private Sub cmdLaatste_Clic k(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdLaatste.Clic k
crViewer.ShowLa stPage()
End Sub

Private Sub cmdTerug_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdTerug.Click
crViewer.ShowPr eviousPage()
End Sub

Private Sub cmdVerder_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdVerder.Click
crViewer.ShowNe xtPage()
End Sub

Private Sub drpZoom_Selecte dIndexChanged(B yVal sender As Object, ByVal e
As System.EventArg s) Handles drpZoom.Selecte dIndexChanged
crViewer.Zoom(d rpZoom.Selected Item.Value)
End Sub

#End Region
"Alison Givens" <in**@cross-it.nl> wrote in message
news:%2******** **********@TK2M SFTNGP14.phx.gb l...
Perhaps you could share your resulting code for comparison? Did you see
that I suggested the error in your code was

myReport.SetPar ameterValue("Fi liaalKeuze", discreteVal) 'You only call
this statement once (Effectively 2344) but you wanted two values.


To get the thing going, it would be enough for me at first to know how to
call the statement twice, so the other value is forwarded too.
(btw, these two values will be SessionObjects two, but I did it hardcoded
for testing)
Best would be ofcourse that I learn to do it 'clean' of course. I am a
real newbee at this.

Here is the rest of my code:

Imports CrystalDecision s.CrystalReport s.Engine
Imports CrystalDecision s.CrystalReport s.Engine.Report Document
Imports CrystalDecision s.Shared
Imports System.IO
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()

Dim myReport As RapportAIRCOSto ringen
Dim paramFields As ParameterFields
Dim paramField As ParameterField

Dim BeginPeriode As String
Dim EindPeriode As String

'Todo wrap everything in try
paramFields = New ParameterFields

Try
BeginPeriode = Request.QuerySt ring("BeginPeri ode")
EindPeriode = Request.QuerySt ring("EindPerio de")
Catch ex As Exception
Dim exCustom As ApplicationExce ption
exCustom = New ApplicationExce ption("Unable to parse Query
Paramaters.", ex)
Throw exCustom
End Try

'Todo wrap in try
paramField = CreateParameter ("FiliaalKeuze" )
paramField.Curr entValues.Add(C reateParameterD iscreteValue(20 44))
paramField.Curr entValues.Add(C reateParameterD iscreteValue(23 44))
myReport.SetPar ameterValue("Fi liaalKeuze", paramField)
'Todo wrap in try
paramField = CreateParameter ("Periode")

paramField.Curr entValues.Add(C reateParameterR angeValue(Begin Periode,
EindPeriode))
myReport.SetPar ameterValue("Pe riode", paramField)
crViewer.Report Source = myReport
'exporteren to pdf
Dim myExportOptions As CrystalDecision s.Shared.Export Options
Dim myDiskFileDesti nationOptions As
CrystalDecision s.Shared.DiskFi leDestinationOp tions
Dim myExportFile As String

myExportFile = "\\192.168.2.10 6\syn2sql$\PDF_ " &
Session.Session ID.ToString & ".pdf"
myDiskFileDesti nationOptions = New
CrystalDecision s.Shared.DiskFi leDestinationOp tions
myDiskFileDesti nationOptions.D iskFileName = myExportFile
myExportOptions = myReport.Export Options
With myExportOptions
.DestinationOpt ions = myDiskFileDesti nationOptions
.ExportDestinat ionType = .ExportDestinat ionType.DiskFil e
.ExportFormatTy pe = .ExportFormatTy pe.PortableDocF ormat
End With

Try
myReport.Export ()
Catch err As Exception
Response.Write( "<BR>")
Response.Write( err.Message.ToS tring)
End Try

Session("export bestand") = myExportFile
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
Private Sub cmdPrint_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdPrint.Click
Response.ClearC ontent()
Response.ClearH eaders()
Response.Conten tType = "applicatio n/pdf"
Dim myExportFile As String = CType(Session.I tem("exportbest and"),
String)

Response.WriteF ile(myExportFil e)
Response.Flush( )
Response.Close( )

System.IO.File. Delete(myExport File)
End Sub

Private Function CreateParameter (ByVal ParameterName As String) As
ParameterField( )
Dim paramField As ParameterField

paramField = New ParameterField
paramField.Para meterFieldName = ParameterName

'Return paramField

End Function

Private Function CreateParameter DiscreteValue(B yVal Value As Object) As
ParameterDiscre teValue()

Dim paramDiscreteVa lue As ParameterDiscre teValue
paramDiscreteVa lue = New ParameterDiscre teValue
paramDiscreteVa lue = Value

'Return paramDiscreteVa lue

End Function

Private Function CreateParameter RangeValue(ByVa l StartRange As Object,
ByVal EndRange As Object) As ParameterRangeV alue
Dim paramRangeValue As ParameterRangeV alue

paramRangeValue = New ParameterRangeV alue

paramRangeValue .StartValue = StartRange
paramRangeValue .EndValue = EndRange

Return paramRangeValue
End Function
Private Sub cmdEerste_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdEerste.Click
crViewer.ShowFi rstPage()
End Sub

Private Sub cmdLaatste_Clic k(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdLaatste.Clic k
crViewer.ShowLa stPage()
End Sub

Private Sub cmdTerug_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdTerug.Click
crViewer.ShowPr eviousPage()
End Sub

Private Sub cmdVerder_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdVerder.Click
crViewer.ShowNe xtPage()
End Sub

Private Sub drpZoom_Selecte dIndexChanged(B yVal sender As Object, ByVal
e As System.EventArg s) Handles drpZoom.Selecte dIndexChanged
crViewer.Zoom(d rpZoom.Selected Item.Value)
End Sub
Private Sub Page_Unload(ByV al sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Unload
Dim myExportFile As String = CType(Session.I tem("exportbest and"),
String)

System.IO.File. Delete(myExport File)
End Sub
End Class


"Alison Givens" <in**@cross-it.nl> wrote in message
news:ee******** ******@TK2MSFTN GP09.phx.gbl...
When I use your solution I get blue lines under the text like this

paramField = CreateParamater ("FiliaalKeuze" )
The text is:
Value of type '1 dimensional array of
CrystalDecision s.Shared.Parame terField' cannot be converted
to 'Crystal.Decisi ons.Shared.Para meterField'

Return paramField
The text is:
Value of type 'CrystalDecisio ns.Shared.Param eterField' cannot be
converted
to '1 dimensional array of Crystal.Decisio ns.Shared.Param eterField'

Same for
paramField = CreateParamater ("Periode")
Return paramDiscreteVa lue

Any idea what causes this?

Alison
"AMDRIT" <am****@hotmail .com> wrote in message
news:ur******** *****@TK2MSFTNG P14.phx.gbl...
Wow, you do all that for Crystal Reports? What is
RapportAIRCOSto ringen?
Here is all I do for CR

Dim x As CrystalDecision s.CrystalReport s.Engine.Report Document

x.Load(sReportP ath) 'Reports are not embedded resources
x.SetParameterV alue("Paramater 1", Paramaters(1)) 'Dynamic
Paramaters
x.SetParameterV alue("Paramater 2", Paramaters(2))
x.SetDataSource (mydata) 'Strongly Typed Datasets

Me.CrystalRepor tViewer1.Report Source = x
Me.CrystalRepor tViewer1.PrintR eport()
'Now to answer your question about your code, hmm

Ok, first

Never --> Dim x as new object
'This is silly, lazy and unprofessional. So if you are in high
school, keep the course.
Instead --> Dim x as object
Set x = new object
'Reserve your space and contract
'Then make use of it.

I think this is your problem

myReport.SetPar ameterValue("Fi liaalKeuze", discreteVal)

Why are you setting the crView paramaters and the myReport paramaters?
-->crViewer.Param eterFieldInfo = paramFields
-->myReport.SetPa rameterValue("P eriode", rangeVal)

I think that myReport is the only think that needs to be set
I had to spent time reading your code to understand what you were
doing.

Here is an attempt to clean it up.

Private Sub TestIT()

Dim myReport As RapportAIRCOSto ringen
Dim paramFields As ParameterFields
Dim paramField As ParameterField

Dim BeginPeriode As String
Dim EindPeriode As String

'Todo wrap everything in try
paramFields = New ParameterFields

Try
BeginPeriode = Request.QuerySt ring("BeginPeri ode")
EindPeriode = Request.QuerySt ring("EindPerio de")
Catch ex As Exception
Dim exCustom As ApplicationExce ption
exCustom = New ApplicationExce ption("Unable to parse Query
Paramaters.", ex)
Throw exCustom
End Try

'Todo wrap in try
paramField = CreateParamater ("FiliaalKeuze" )
paramField.Curr entValues.Add(C reateParameterD iscreteValue(20 44))
paramField.Curr entValues.Add(C reateParameterD iscreteValue(23 44))
myReport.SetPar ameterValue("Fi liaalKeuze", paramField)
'paramFields.Ad d(paramField) --> Not needed

'Todo wrap in try
paramField = CreateParamater ("Periode")
paramField.Curr entValues.Add(C reateParameterR angeValue(Begin Periode,
EindPeriode))
myReport.SetPar ameterValue("Pe riode", paramField)
'paramFields.Ad d(paramField)--> Not needed

'Todo wrap in try, i don't think you need this
'myReport.SetPa rameterValue("P eriode", rangeVal)
'myReport.SetPa rameterValue("F iliaalKeuze", discreteVal)

'Todo, determine if we need this step; I don't think you do
'crViewer.Param eterFieldInfo = paramFields

crViewer.Report Source = myReport

End Sub

Private Function CreateParamater (ByVal ParamaterName As String) As
ParameterField
Dim paramField As ParameterField

paramField = New ParameterField
paramField.Para meterFieldName = ParamaterName

Return paramField

End Function

Private Function CreateParameter DiscreteValue(B yVal Value As Object)
As ParameterDiscre teValue

Dim paramDiscreteVa lue As ParameterDiscre teValue
paramDiscreteVa lue = New ParameterDiscre teValue
paramDiscreteVa lue = Value

Return paramDiscreteVa lue

End Function

Private Function CreateParameter RangeValue(ByVa l StartRange As Object,
ByVal EndRange As Object) As ParameterRangeV alue
Dim paramRangeValue As ParameterRangeV alue

paramRangeValue = New ParameterRangeV alue

paramRangeValue .StartValue = StartRange
paramRangeValue .EndValue = EndRange

Return paramRangeValue
End Function

"Alison Givens" <in**@cross-it.nl> wrote in message
news:eW******** *****@TK2MSFTNG P11.phx.gbl...
> ...... that nobody knows the answer.
> I can't imagine that I am the only one that uses parameters in CR.
>
> So, my question again:
>
> I have the following problem.
> (VB.NET 2003 with CR)
>
> I have a report with a multiple-value discrete value and a rangevalue.
> The report shows fine in the viewer, but when I hit the export to pdf
> button, it only uses one of two discrete values.
>
> This is the code:
> Dim BeginPeriode As String
> Dim EindPeriode As String
>
> BeginPeriode = Request.QuerySt ring("BeginPeri ode")
> EindPeriode = Request.QuerySt ring("EindPerio de")
>
> Dim myReport As New RapportAIRCOSto ringen
>
> Dim paramFields As New ParameterFields
> Dim paramField As New ParameterField
> Dim discreteVal As New ParameterDiscre teValue
> Dim rangeVal As New ParameterRangeV alue
>
> paramField.Para meterFieldName = "FiliaalKeu ze"
> discreteVal.Val ue = "2044"
> paramField.Curr entValues.Add(d iscreteVal)
>
> discreteVal = New ParameterDiscre teValue
> discreteVal.Val ue = "2344"
> paramField.Curr entValues.Add(d iscreteVal)
>
> paramFields.Add (paramField)
>
> paramField = New ParameterField
>
> paramField.Para meterFieldName = "Periode"
>
> rangeVal.StartV alue = BeginPeriode
> rangeVal.EndVal ue = EindPeriode
> paramField.Curr entValues.Add(r angeVal)
>
> paramFields.Add (paramField)
>
> crViewer.Parame terFieldInfo = paramFields
> myReport.SetPar ameterValue("Pe riode", rangeVal)
> myReport.SetPar ameterValue("Fi liaalKeuze", discreteVal)
> crViewer.Report Source = myReport
>
> As you can see I use myReport.SetPar ameterValue to feed the pdf.
> It goes wrong with the discrete value. It only sees the second value I
> entered and not the first.
> How can I get this going?
>
>
> Kind regards,
> Alison
>
>
>
>



Feb 20 '06 #6
I used the code as you suggested, but again I get blue underlines.
First with every GetSessionValue ,it has a blue underline:
Name GetSessionValue is not declared

and the other blue underline is GetExportRoot
myExportFile = System.IO.Path. Combine(GetExpo rtRoot,
String.Format(" PDF_{0}.pdf", myExportFile))
Says:Argument not specified for parameter 'FromApplicatio n' of
'Private Function GetExportRoot(F romApplication As Boolean) As String'.

I pasted the code again for your convenience.

Private Enum FileNameFormats
SessionID = 0
GUIDDashes = 1
GUIDNoDashes = 2
End Enum
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()
Dim myReport As RapportAIRCOSto ringen
Dim myExportOptions As CrystalDecision s.Shared.Export Options

Try

Try
PrepareReport(m yReport)
Catch ex As Exception
Dim exc As ApplicationExce ption
exc = New ApplicationExce ption("Unable to prepare report.",
ex)
Throw exc
End Try

Try
'exporteren to pdf
myExportOptions =
GetExportOption s(FileNameForma ts.GUIDNoDashes , CType(myReport,
CrystalDecision s.CrystalReport s.Engine.Report Document).Expor tOptions)
myReport.Export ()

Catch ex As Exception
Dim exc As ApplicationExce ption
exc = New ApplicationExce ption("Unable to export report.",
ex)
Throw exc
End Try

crViewer.Report Source = myReport

Session("export bestand") =
CType(myExportO ptions.Destinat ionOptions,
CrystalDecision s.Shared.DiskFi leDestinationOp tions).DiskFile Name

Catch err As Exception
Response.Write( "<BR>")
Response.Write( err.Message.ToS tring)
End Try


End Sub

#End Region

#Region "Page Implementation"

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Private Sub Page_Unload(ByV al sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Unload
Dim myExportFile As String = CType(Session.I tem("exportbest and"),
String)

System.IO.File. Delete(myExport File)
End Sub

#End Region

#Region "Report Setup"

Private Sub PrepareReport(B yVal myReport As
CrystalDecision s.CrystalReport s.Engine.Report Document)

Dim paramFields As ParameterFields
Dim paramField As ParameterField

Const SessionExecptio n As String = "Unable to read session objects."

Try

paramFields = New ParameterFields
Try
paramField = CreateParameter ("FiliaalKeuze" )
paramField.Curr entValues.Add(C reateParameterD iscreteValue(Ge tSessionValue(" DiscreteValue1" )))
paramField.Curr entValues.Add(C reateParameterD iscreteValue(Ge tSessionValue(" DiscreteValue1" )))

Catch ex As Exception
Dim exc As System.Applicat ionException
exc = New System.Applicat ionException(Se ssionExecption, ex)
Throw exc
End Try

myReport.SetPar ameterValue("Fi liaalKeuze", paramField)

Try
'Todo wrap in try
paramField = CreateParameter ("Periode")
paramField.Curr entValues.Add(C reateParameterR angeValue(GetSe ssionValue("Beg inPeriode"),
GetSessionValue ("EindPeriode") ))
Catch ex As Exception
Dim exc As System.Applicat ionException
exc = New System.Applicat ionException(Se ssionExecption, ex)
Throw exc
End Try

myReport.SetPar ameterValue("Pe riode", paramField)

Catch ex As Exception

Dim exc As System.Applicat ionException
exc = New System.Applicat ionException("U nable to set
paramatervalue. ", ex)
Throw exc

End Try
End Sub

Private Function CreateParameter (ByVal ParameterName As String) As
ParameterField
Dim paramField As ParameterField

paramField = New ParameterField
paramField.Para meterFieldName = ParameterName

Return paramField

End Function

Private Function CreateParameter DiscreteValue(B yVal Value As Object) As
ParameterDiscre teValue

Dim paramDiscreteVa lue As ParameterDiscre teValue
paramDiscreteVa lue = New ParameterDiscre teValue
paramDiscreteVa lue = Value

Return paramDiscreteVa lue

End Function

Private Function CreateParameter RangeValue(ByVa l StartRange As Object,
ByVal EndRange As Object) As ParameterRangeV alue
Dim paramRangeValue As ParameterRangeV alue

paramRangeValue = New ParameterRangeV alue

paramRangeValue .StartValue = StartRange
paramRangeValue .EndValue = EndRange

Return paramRangeValue
End Function

#End Region

#Region "Report Export"

Private Function GetExportOption s(ByVal UniqueFormat As FileNameFormats ,
ByVal ExportOptions As CrystalDecision s.Shared.Export Options) As
CrystalDecision s.Shared.Export Options

Dim myExportFile As String
Dim myExportOptions As CrystalDecision s.Shared.Export Options
Dim myDiskFileDesti nationOptions As
CrystalDecision s.Shared.DiskFi leDestinationOp tions

Try

Select Case UniqueFormat
Case FileNameFormats .SessionID
myExportFile = Session.Session ID.ToString
Case FileNameFormats .GUIDDashes
myExportFile = System.Guid.New Guid.ToString(" D")
Case FileNameFormats .GUIDNoDashes
myExportFile = System.Guid.New Guid.ToString(" N")
End Select

myExportFile = System.IO.Path. Combine(GetExpo rtRoot,
String.Format(" PDF_{0}.pdf", myExportFile))

myDiskFileDesti nationOptions = New
CrystalDecision s.Shared.DiskFi leDestinationOp tions
myDiskFileDesti nationOptions.D iskFileName = myExportFile

myExportOptions = ExportOptions

With myExportOptions
.DestinationOpt ions = myDiskFileDesti nationOptions
.ExportDestinat ionType = .ExportDestinat ionType.DiskFil e
.ExportFormatTy pe = .ExportFormatTy pe.PortableDocF ormat
End With

Catch ex As Exception

Dim exc As System.Applicat ionException
exc = New System.Applicat ionException("U nable to prepare export
options.", ex)
Throw exc

End Try

Return myExportOptions

End Function

Private Function GetExportRoot(B yVal FromApplication As Boolean) As
String

Dim strExportRoot As String

If FromApplication Then
Try
Application.Loc k()
strExportRoot = Application("Re portExportRoot" )
Catch ex As Exception
Dim exc As ApplicationExce ption
exc = New ApplicationExce ption("Unable to lock Web
Application for read.", ex)
Throw exc
Finally
Application.UnL ock()
End Try
Else
strExportRoot = Session("Report ExportRoot")
End If

Return strExportRoot

End Function

#End Region

#Region "Navigation Implementation"

Private Sub cmdPrint_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdPrint.Click

Response.ClearC ontent()
Response.ClearH eaders()
Response.Conten tType = "applicatio n/pdf"

Dim myExportFile As String = CType(Session.I tem("exportbest and"),
String)

Response.WriteF ile(myExportFil e)
Response.Flush( )
Response.Close( )

System.IO.File. Delete(myExport File)

End Sub

Private Sub cmdEerste_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdEerste.Click
crViewer.ShowFi rstPage()
End Sub

Private Sub cmdLaatste_Clic k(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdLaatste.Clic k
crViewer.ShowLa stPage()
End Sub

Private Sub cmdTerug_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdTerug.Click
crViewer.ShowPr eviousPage()
End Sub

Private Sub cmdVerder_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdVerder.Click
crViewer.ShowNe xtPage()
End Sub

Private Sub drpZoom_Selecte dIndexChanged(B yVal sender As Object, ByVal e
As System.EventArg s) Handles drpZoom.Selecte dIndexChanged
crViewer.Zoom(d rpZoom.Selected Item.Value)
End Sub

#End Region
End Class


"AMDRIT" <am****@hotmail .com> wrote in message
news:Op******** ******@TK2MSFTN GP09.phx.gbl...
Ok, first the isue you were having with the "Blue lines" is:

Private Function CreateParameter DiscreteValue(B yVal Value As Object) As
ParameterDiscre teValue()
--> Retun type is expecting an array of ParameterDiscre teValue

it should be

Private Function CreateParameter DiscreteValue(B yVal Value As Object) As
ParameterDiscre teValue
--> Retun type is expecting an single ParameterDiscre teValue

Second (Mostly because I was bored and also because I am still a novice),
I have altered your code yet again.
Private Enum FileNameFormats
SessionID = 0
GUIDDashes = 1
GUIDNoDashes = 2
End Enum

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()

Dim myReport As RapportAIRCOSto ringen
Dim myExportOptions As CrystalDecision s.Shared.Export Options

Try

Try
PrepareReport(m yReport)
Catch ex As Exception
Dim exc As ApplicationExce ption
exc = New ApplicationExce ption("Unable to prepare report.", ex)
Throw exc
End Try

Try
'exporteren to pdf
myExportOptions = GetExportOption s(FileNameForma ts.GUIDNoDashes ,
CType(myReport,
CrystalDecision s.CrystalReport s.Engine.Report Document).Expor tOptions)
myReport.Export ()

Catch ex As Exception
Dim exc As ApplicationExce ption
exc = New ApplicationExce ption("Unable to export report.", ex)
Throw exc
End Try

crViewer.Report Source = myReport

Session("export bestand") = CType(myExportO ptions.Destinat ionOptions,
CrystalDecision s.Shared.DiskFi leDestinationOp tions).DiskFile Name

Catch err As Exception
Response.Write( "<BR>")
Response.Write( err.Message.ToS tring)
End Try

End Sub

#Region "Page Implementation"

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Private Sub Page_Unload(ByV al sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Unload
Dim myExportFile As String = CType(Session.I tem("exportbest and"),
String)

System.IO.File. Delete(myExport File)
End Sub

#End Region

#Region "Report Setup"

Private Sub PrepareReport(B yVal myReport As
CrystalDecision s.CrystalReport s.Engine.Report Document)

Dim paramFields As ParameterFields
Dim paramField As ParameterField

Const SessionExecptio n As String = "Unable to read session objects."

Try

paramFields = New ParameterFields
Try
paramField = CreateParameter ("FiliaalKeuze" )

paramField.Curr entValues.Add(C reateParameterD iscreteValue(Ge tSessionValue(" DiscreteValue1" )))

paramField.Curr entValues.Add(C reateParameterD iscreteValue(Ge tSessionValue(" DiscreteValue1" )))
Catch ex As Exception
Dim exc As System.Applicat ionException
exc = New System.Applicat ionException(Se ssionExecption, ex)
Throw exc
End Try

myReport.SetPar ameterValue("Fi liaalKeuze", paramField)

Try
'Todo wrap in try
paramField = CreateParameter ("Periode")

paramField.Curr entValues.Add(C reateParameterR angeValue(GetSe ssionValue("Beg inPeriode"),
GetSessionValue ("EindPeriode") ))
Catch ex As Exception
Dim exc As System.Applicat ionException
exc = New System.Applicat ionException(Se ssionExecption, ex)
Throw exc
End Try

myReport.SetPar ameterValue("Pe riode", paramField)

Catch ex As Exception

Dim exc As System.Applicat ionException
exc = New System.Applicat ionException("U nable to set paramater
value.", ex)
Throw exc

End Try
End Sub

Private Function CreateParameter (ByVal ParameterName As String) As
ParameterField
Dim paramField As ParameterField

paramField = New ParameterField
paramField.Para meterFieldName = ParameterName

Return paramField

End Function

Private Function CreateParameter DiscreteValue(B yVal Value As Object) As
ParameterDiscre teValue()

Dim paramDiscreteVa lue As ParameterDiscre teValue
paramDiscreteVa lue = New ParameterDiscre teValue
paramDiscreteVa lue = Value

'Return paramDiscreteVa lue

End Function

Private Function CreateParameter RangeValue(ByVa l StartRange As Object,
ByVal EndRange As Object) As ParameterRangeV alue
Dim paramRangeValue As ParameterRangeV alue

paramRangeValue = New ParameterRangeV alue

paramRangeValue .StartValue = StartRange
paramRangeValue .EndValue = EndRange

Return paramRangeValue
End Function

#End Region

#Region "Report Export"

Private Function GetExportOption s(ByVal UniqueFormat As FileNameFormats ,
ByVal ExportOptions As CrystalDecision s.Shared.Export Options) As
CrystalDecision s.Shared.Export Options

Dim myExportFile As String
Dim myExportOptions As CrystalDecision s.Shared.Export Options
Dim myDiskFileDesti nationOptions As
CrystalDecision s.Shared.DiskFi leDestinationOp tions

Try

Select Case UniqueFormat
Case FileNameFormats .SessionID
myExportFile = Session.Session ID.ToString
Case FileNameFormats .GUIDDashes
myExportFile = System.Guid.New Guid.ToString(" D")
Case FileNameFormats .GUIDNoDashes
myExportFile = System.Guid.New Guid.ToString(" N")
End Select

myExportFile = System.IO.Path. Combine(GetExpo rtRoot,
String.Format(" PDF_{0}.pdf", myExportFile))

myDiskFileDesti nationOptions = New
CrystalDecision s.Shared.DiskFi leDestinationOp tions
myDiskFileDesti nationOptions.D iskFileName = myExportFile

myExportOptions = ExportOptions

With myExportOptions
.DestinationOpt ions = myDiskFileDesti nationOptions
.ExportDestinat ionType = .ExportDestinat ionType.DiskFil e
.ExportFormatTy pe = .ExportFormatTy pe.PortableDocF ormat
End With

Catch ex As Exception

Dim exc As System.Applicat ionException
exc = New System.Applicat ionException("U nable to prepare export
options.", ex)
Throw exc

End Try

Return myExportOptions

End Function

Private Function GetExportRoot(B yVal FromApplication As Boolean) As
String

Dim strExportRoot As String

If FromApplication Then
Try
Application.loc k()
strExportRoot = Application("Re portExportRoot" )
Catch ex As Exception
Dim exc As ApplicationExce ption
exc = New ApplicationExce ption("Unable to lock Web Application for
read.", ex)
Throw exc
Finally
Application.unl ock()
End Try
Else
strExportRoot = Session("Report ExportRoot")
End If

Return strExportRoot

End Function

#End Region

#Region "Navigation Implementation"

Private Sub cmdPrint_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdPrint.Click

Response.ClearC ontent()
Response.ClearH eaders()
Response.Conten tType = "applicatio n/pdf"

Dim myExportFile As String = CType(Session.I tem("exportbest and"),
String)

Response.WriteF ile(myExportFil e)
Response.Flush( )
Response.Close( )

System.IO.File. Delete(myExport File)

End Sub

Private Sub cmdEerste_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdEerste.Click
crViewer.ShowFi rstPage()
End Sub

Private Sub cmdLaatste_Clic k(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdLaatste.Clic k
crViewer.ShowLa stPage()
End Sub

Private Sub cmdTerug_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdTerug.Click
crViewer.ShowPr eviousPage()
End Sub

Private Sub cmdVerder_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdVerder.Click
crViewer.ShowNe xtPage()
End Sub

Private Sub drpZoom_Selecte dIndexChanged(B yVal sender As Object, ByVal e
As System.EventArg s) Handles drpZoom.Selecte dIndexChanged
crViewer.Zoom(d rpZoom.Selected Item.Value)
End Sub

#End Region
"Alison Givens" <in**@cross-it.nl> wrote in message
news:%2******** **********@TK2M SFTNGP14.phx.gb l...
Perhaps you could share your resulting code for comparison? Did you see
that I suggested the error in your code was

myReport.SetPar ameterValue("Fi liaalKeuze", discreteVal) 'You only call
this statement once (Effectively 2344) but you wanted two values.


To get the thing going, it would be enough for me at first to know how to
call the statement twice, so the other value is forwarded too.
(btw, these two values will be SessionObjects two, but I did it hardcoded
for testing)
Best would be ofcourse that I learn to do it 'clean' of course. I am a
real newbee at this.

Here is the rest of my code:

Imports CrystalDecision s.CrystalReport s.Engine
Imports CrystalDecision s.CrystalReport s.Engine.Report Document
Imports CrystalDecision s.Shared
Imports System.IO
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()

Dim myReport As RapportAIRCOSto ringen
Dim paramFields As ParameterFields
Dim paramField As ParameterField

Dim BeginPeriode As String
Dim EindPeriode As String

'Todo wrap everything in try
paramFields = New ParameterFields

Try
BeginPeriode = Request.QuerySt ring("BeginPeri ode")
EindPeriode = Request.QuerySt ring("EindPerio de")
Catch ex As Exception
Dim exCustom As ApplicationExce ption
exCustom = New ApplicationExce ption("Unable to parse Query
Paramaters.", ex)
Throw exCustom
End Try

'Todo wrap in try
paramField = CreateParameter ("FiliaalKeuze" )
paramField.Curr entValues.Add(C reateParameterD iscreteValue(20 44))
paramField.Curr entValues.Add(C reateParameterD iscreteValue(23 44))
myReport.SetPar ameterValue("Fi liaalKeuze", paramField)
'Todo wrap in try
paramField = CreateParameter ("Periode")

paramField.Curr entValues.Add(C reateParameterR angeValue(Begin Periode,
EindPeriode))
myReport.SetPar ameterValue("Pe riode", paramField)
crViewer.Report Source = myReport
'exporteren to pdf
Dim myExportOptions As CrystalDecision s.Shared.Export Options
Dim myDiskFileDesti nationOptions As
CrystalDecision s.Shared.DiskFi leDestinationOp tions
Dim myExportFile As String

myExportFile = "\\192.168.2.10 6\syn2sql$\PDF_ " &
Session.Session ID.ToString & ".pdf"
myDiskFileDesti nationOptions = New
CrystalDecision s.Shared.DiskFi leDestinationOp tions
myDiskFileDesti nationOptions.D iskFileName = myExportFile
myExportOptions = myReport.Export Options
With myExportOptions
.DestinationOpt ions = myDiskFileDesti nationOptions
.ExportDestinat ionType = .ExportDestinat ionType.DiskFil e
.ExportFormatTy pe = .ExportFormatTy pe.PortableDocF ormat
End With

Try
myReport.Export ()
Catch err As Exception
Response.Write( "<BR>")
Response.Write( err.Message.ToS tring)
End Try

Session("export bestand") = myExportFile
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
Private Sub cmdPrint_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdPrint.Click
Response.ClearC ontent()
Response.ClearH eaders()
Response.Conten tType = "applicatio n/pdf"
Dim myExportFile As String = CType(Session.I tem("exportbest and"),
String)

Response.WriteF ile(myExportFil e)
Response.Flush( )
Response.Close( )

System.IO.File. Delete(myExport File)
End Sub

Private Function CreateParameter (ByVal ParameterName As String) As
ParameterField( )
Dim paramField As ParameterField

paramField = New ParameterField
paramField.Para meterFieldName = ParameterName

'Return paramField

End Function

Private Function CreateParameter DiscreteValue(B yVal Value As Object)
As ParameterDiscre teValue()

Dim paramDiscreteVa lue As ParameterDiscre teValue
paramDiscreteVa lue = New ParameterDiscre teValue
paramDiscreteVa lue = Value

'Return paramDiscreteVa lue

End Function

Private Function CreateParameter RangeValue(ByVa l StartRange As Object,
ByVal EndRange As Object) As ParameterRangeV alue
Dim paramRangeValue As ParameterRangeV alue

paramRangeValue = New ParameterRangeV alue

paramRangeValue .StartValue = StartRange
paramRangeValue .EndValue = EndRange

Return paramRangeValue
End Function
Private Sub cmdEerste_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdEerste.Click
crViewer.ShowFi rstPage()
End Sub

Private Sub cmdLaatste_Clic k(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdLaatste.Clic k
crViewer.ShowLa stPage()
End Sub

Private Sub cmdTerug_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdTerug.Click
crViewer.ShowPr eviousPage()
End Sub

Private Sub cmdVerder_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdVerder.Click
crViewer.ShowNe xtPage()
End Sub

Private Sub drpZoom_Selecte dIndexChanged(B yVal sender As Object, ByVal
e As System.EventArg s) Handles drpZoom.Selecte dIndexChanged
crViewer.Zoom(d rpZoom.Selected Item.Value)
End Sub
Private Sub Page_Unload(ByV al sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Unload
Dim myExportFile As String = CType(Session.I tem("exportbest and"),
String)

System.IO.File. Delete(myExport File)
End Sub
End Class


"Alison Givens" <in**@cross-it.nl> wrote in message
news:ee******** ******@TK2MSFTN GP09.phx.gbl...
When I use your solution I get blue lines under the text like this

paramField = CreateParamater ("FiliaalKeuze" )
The text is:
Value of type '1 dimensional array of
CrystalDecision s.Shared.Parame terField' cannot be converted
to 'Crystal.Decisi ons.Shared.Para meterField'

Return paramField
The text is:
Value of type 'CrystalDecisio ns.Shared.Param eterField' cannot be
converted
to '1 dimensional array of Crystal.Decisio ns.Shared.Param eterField'

Same for
paramField = CreateParamater ("Periode")
Return paramDiscreteVa lue

Any idea what causes this?

Alison
"AMDRIT" <am****@hotmail .com> wrote in message
news:ur******** *****@TK2MSFTNG P14.phx.gbl...
> Wow, you do all that for Crystal Reports? What is
> RapportAIRCOSto ringen?
>
>
> Here is all I do for CR
>
> Dim x As CrystalDecision s.CrystalReport s.Engine.Report Document
>
> x.Load(sReportP ath) 'Reports are not embedded resources
> x.SetParameterV alue("Paramater 1", Paramaters(1)) 'Dynamic
> Paramaters
> x.SetParameterV alue("Paramater 2", Paramaters(2))
> x.SetDataSource (mydata) 'Strongly Typed Datasets
>
> Me.CrystalRepor tViewer1.Report Source = x
> Me.CrystalRepor tViewer1.PrintR eport()
>
>
> 'Now to answer your question about your code, hmm
>
> Ok, first
>
> Never --> Dim x as new object
> 'This is silly, lazy and unprofessional. So if you are in high
> school, keep the course.
>
>
> Instead --> Dim x as object
> Set x = new object
> 'Reserve your space and contract
> 'Then make use of it.
>
> I think this is your problem
>
> myReport.SetPar ameterValue("Fi liaalKeuze", discreteVal)
>
> Why are you setting the crView paramaters and the myReport paramaters?
> -->crViewer.Param eterFieldInfo = paramFields
> -->myReport.SetPa rameterValue("P eriode", rangeVal)
>
> I think that myReport is the only think that needs to be set
>
>
> I had to spent time reading your code to understand what you were
> doing.
>
> Here is an attempt to clean it up.
>
> Private Sub TestIT()
>
> Dim myReport As RapportAIRCOSto ringen
> Dim paramFields As ParameterFields
> Dim paramField As ParameterField
>
> Dim BeginPeriode As String
> Dim EindPeriode As String
>
> 'Todo wrap everything in try
> paramFields = New ParameterFields
>
> Try
> BeginPeriode = Request.QuerySt ring("BeginPeri ode")
> EindPeriode = Request.QuerySt ring("EindPerio de")
> Catch ex As Exception
> Dim exCustom As ApplicationExce ption
> exCustom = New ApplicationExce ption("Unable to parse Query
> Paramaters.", ex)
> Throw exCustom
> End Try
>
> 'Todo wrap in try
> paramField = CreateParamater ("FiliaalKeuze" )
> paramField.Curr entValues.Add(C reateParameterD iscreteValue(20 44))
> paramField.Curr entValues.Add(C reateParameterD iscreteValue(23 44))
> myReport.SetPar ameterValue("Fi liaalKeuze", paramField)
> 'paramFields.Ad d(paramField) --> Not needed
>
> 'Todo wrap in try
> paramField = CreateParamater ("Periode")
>
> paramField.Curr entValues.Add(C reateParameterR angeValue(Begin Periode,
> EindPeriode))
> myReport.SetPar ameterValue("Pe riode", paramField)
> 'paramFields.Ad d(paramField)--> Not needed
>
> 'Todo wrap in try, i don't think you need this
> 'myReport.SetPa rameterValue("P eriode", rangeVal)
> 'myReport.SetPa rameterValue("F iliaalKeuze", discreteVal)
>
> 'Todo, determine if we need this step; I don't think you do
> 'crViewer.Param eterFieldInfo = paramFields
>
> crViewer.Report Source = myReport
>
> End Sub
>
> Private Function CreateParamater (ByVal ParamaterName As String) As
> ParameterField
> Dim paramField As ParameterField
>
> paramField = New ParameterField
> paramField.Para meterFieldName = ParamaterName
>
> Return paramField
>
> End Function
>
> Private Function CreateParameter DiscreteValue(B yVal Value As Object)
> As ParameterDiscre teValue
>
> Dim paramDiscreteVa lue As ParameterDiscre teValue
> paramDiscreteVa lue = New ParameterDiscre teValue
> paramDiscreteVa lue = Value
>
> Return paramDiscreteVa lue
>
> End Function
>
> Private Function CreateParameter RangeValue(ByVa l StartRange As
> Object, ByVal EndRange As Object) As ParameterRangeV alue
> Dim paramRangeValue As ParameterRangeV alue
>
> paramRangeValue = New ParameterRangeV alue
>
> paramRangeValue .StartValue = StartRange
> paramRangeValue .EndValue = EndRange
>
> Return paramRangeValue
> End Function
>
> "Alison Givens" <in**@cross-it.nl> wrote in message
> news:eW******** *****@TK2MSFTNG P11.phx.gbl...
>> ...... that nobody knows the answer.
>> I can't imagine that I am the only one that uses parameters in CR.
>>
>> So, my question again:
>>
>> I have the following problem.
>> (VB.NET 2003 with CR)
>>
>> I have a report with a multiple-value discrete value and a
>> rangevalue.
>> The report shows fine in the viewer, but when I hit the export to pdf
>> button, it only uses one of two discrete values.
>>
>> This is the code:
>> Dim BeginPeriode As String
>> Dim EindPeriode As String
>>
>> BeginPeriode = Request.QuerySt ring("BeginPeri ode")
>> EindPeriode = Request.QuerySt ring("EindPerio de")
>>
>> Dim myReport As New RapportAIRCOSto ringen
>>
>> Dim paramFields As New ParameterFields
>> Dim paramField As New ParameterField
>> Dim discreteVal As New ParameterDiscre teValue
>> Dim rangeVal As New ParameterRangeV alue
>>
>> paramField.Para meterFieldName = "FiliaalKeu ze"
>> discreteVal.Val ue = "2044"
>> paramField.Curr entValues.Add(d iscreteVal)
>>
>> discreteVal = New ParameterDiscre teValue
>> discreteVal.Val ue = "2344"
>> paramField.Curr entValues.Add(d iscreteVal)
>>
>> paramFields.Add (paramField)
>>
>> paramField = New ParameterField
>>
>> paramField.Para meterFieldName = "Periode"
>>
>> rangeVal.StartV alue = BeginPeriode
>> rangeVal.EndVal ue = EindPeriode
>> paramField.Curr entValues.Add(r angeVal)
>>
>> paramFields.Add (paramField)
>>
>> crViewer.Parame terFieldInfo = paramFields
>> myReport.SetPar ameterValue("Pe riode", rangeVal)
>> myReport.SetPar ameterValue("Fi liaalKeuze", discreteVal)
>> crViewer.Report Source = myReport
>>
>> As you can see I use myReport.SetPar ameterValue to feed the pdf.
>> It goes wrong with the discrete value. It only sees the second value
>> I
>> entered and not the first.
>> How can I get this going?
>>
>>
>> Kind regards,
>> Alison
>>
>>
>>
>>
>
>



Feb 21 '06 #7
Good morning,

I just realized you keep different hours than me. Please keep in mind that
all the code that I have submitted to you is wholly untested and therefore
the jist of what I was conveying should be taken into context. I attempt to
answer your direct question before going off onto a tangent.

1. You need a function named GetSessionValue
The signature would look like: GetSessionValue (KeyName as string) as
object and all it would do is return Session.Item(Ke yName)

2. Correct the line
myExportFile = System.IO.Path. Combine(GetExpo rtRoot,
String.Format(" PDF_{0}.pdf", myExportFile))
to
myExportFile = System.IO.Path. Combine(GetExpo rtRoot(false),
String.Format(" PDF_{0}.pdf", myExportFile))
or
myExportFile = System.IO.Path. Combine(GetExpo rtRoot(true),
String.Format(" PDF_{0}.pdf", myExportFile))

If you are to use the function GetExportRoot, then you must set up your
global.asax to set a global variable to hold ReportExportRoo t in
Application_OnS tart, and if you want each session to get a copy of that
value in the global.asax Session_OnStart , have it read the Application
variable.

The goal here is to store environmental setting information out of compiled
code. It's more work to set it up, but will not require you to compile the
application everytime you want to make a change.

ideal uses for the web config (DbConnection, ServerLocations , FileShares,
WebService URLs)

keep in mind though, each time you modify the webconfig, it spawns a new
instance of your application. Existing users (those already connected) will
not see your changes and will be orphaned from your intended solution.
Changes to the web config, once in production, should be treated as a bug
fix or enhancement that required replacement of binaries.

Example

In your web.config | appsettings section, create a key pair

<Add key="ReportExpo rtRoot" Value = "\\192.168.2.10 6\syn2sql$\PDF_ " />
for more information on appsettings see:
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003 FEB.1033/cpgenref/html/gngrfappsetting selement.htm

in your application's global.asax on Application_OnS tart
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003 FEB.1033/vbcon/html/vbconPageApplic ationContext.ht m
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003 FEB.1033/cpguide/html/cpcontheglobala saxfile.htm

sub application_ons tart()
Dim ReportExportRoo t as string
ReportExportRoo t =
System.Configur ation.Configura tionSettings.Ap pSettings("Repo rtExportRoot")
Application.Loc k
Application("Re portExportRoot" ) = ReportExportRoo t
Application.Unl ock
end sub

in you application's global.asax on Session_OnStart
sub Session_Onstart ()
Dim ReportExportRoo t as string
Application.Loc k
ReportExportRoo t = ctype(Applicati on("ReportExpor tRoot"),string)
Application.Unl ock
Session.item("R eportExportRoot ") = ReportExportRoo t
end sub

"Alison Givens" <in**@cross-it.nl> wrote in message
news:OT******** ******@TK2MSFTN GP11.phx.gbl...
I used the code as you suggested, but again I get blue underlines.
First with every GetSessionValue ,it has a blue underline:
Name GetSessionValue is not declared

and the other blue underline is GetExportRoot
myExportFile = System.IO.Path. Combine(GetExpo rtRoot,
String.Format(" PDF_{0}.pdf", myExportFile))
Says:Argument not specified for parameter 'FromApplicatio n' of
'Private Function GetExportRoot(F romApplication As Boolean) As String'.

I pasted the code again for your convenience.

Private Enum FileNameFormats
SessionID = 0
GUIDDashes = 1
GUIDNoDashes = 2
End Enum
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()
Dim myReport As RapportAIRCOSto ringen
Dim myExportOptions As CrystalDecision s.Shared.Export Options

Try

Try
PrepareReport(m yReport)
Catch ex As Exception
Dim exc As ApplicationExce ption
exc = New ApplicationExce ption("Unable to prepare report.",
ex)
Throw exc
End Try

Try
'exporteren to pdf
myExportOptions =
GetExportOption s(FileNameForma ts.GUIDNoDashes , CType(myReport,
CrystalDecision s.CrystalReport s.Engine.Report Document).Expor tOptions)
myReport.Export ()

Catch ex As Exception
Dim exc As ApplicationExce ption
exc = New ApplicationExce ption("Unable to export report.",
ex)
Throw exc
End Try

crViewer.Report Source = myReport

Session("export bestand") =
CType(myExportO ptions.Destinat ionOptions,
CrystalDecision s.Shared.DiskFi leDestinationOp tions).DiskFile Name

Catch err As Exception
Response.Write( "<BR>")
Response.Write( err.Message.ToS tring)
End Try


End Sub

#End Region

#Region "Page Implementation"

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Private Sub Page_Unload(ByV al sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Unload
Dim myExportFile As String = CType(Session.I tem("exportbest and"),
String)

System.IO.File. Delete(myExport File)
End Sub

#End Region

#Region "Report Setup"

Private Sub PrepareReport(B yVal myReport As
CrystalDecision s.CrystalReport s.Engine.Report Document)

Dim paramFields As ParameterFields
Dim paramField As ParameterField

Const SessionExecptio n As String = "Unable to read session
objects."

Try

paramFields = New ParameterFields
Try
paramField = CreateParameter ("FiliaalKeuze" )

paramField.Curr entValues.Add(C reateParameterD iscreteValue(Ge tSessionValue(" DiscreteValue1" )))

paramField.Curr entValues.Add(C reateParameterD iscreteValue(Ge tSessionValue(" DiscreteValue1" )))

Catch ex As Exception
Dim exc As System.Applicat ionException
exc = New System.Applicat ionException(Se ssionExecption, ex)
Throw exc
End Try

myReport.SetPar ameterValue("Fi liaalKeuze", paramField)

Try
'Todo wrap in try
paramField = CreateParameter ("Periode")

paramField.Curr entValues.Add(C reateParameterR angeValue(GetSe ssionValue("Beg inPeriode"),
GetSessionValue ("EindPeriode") ))
Catch ex As Exception
Dim exc As System.Applicat ionException
exc = New System.Applicat ionException(Se ssionExecption, ex)
Throw exc
End Try

myReport.SetPar ameterValue("Pe riode", paramField)

Catch ex As Exception

Dim exc As System.Applicat ionException
exc = New System.Applicat ionException("U nable to set
paramatervalue. ", ex)
Throw exc

End Try
End Sub

Private Function CreateParameter (ByVal ParameterName As String) As
ParameterField
Dim paramField As ParameterField

paramField = New ParameterField
paramField.Para meterFieldName = ParameterName

Return paramField

End Function

Private Function CreateParameter DiscreteValue(B yVal Value As Object) As
ParameterDiscre teValue

Dim paramDiscreteVa lue As ParameterDiscre teValue
paramDiscreteVa lue = New ParameterDiscre teValue
paramDiscreteVa lue = Value

Return paramDiscreteVa lue

End Function

Private Function CreateParameter RangeValue(ByVa l StartRange As Object,
ByVal EndRange As Object) As ParameterRangeV alue
Dim paramRangeValue As ParameterRangeV alue

paramRangeValue = New ParameterRangeV alue

paramRangeValue .StartValue = StartRange
paramRangeValue .EndValue = EndRange

Return paramRangeValue
End Function

#End Region

#Region "Report Export"

Private Function GetExportOption s(ByVal UniqueFormat As
FileNameFormats , ByVal ExportOptions As
CrystalDecision s.Shared.Export Options) As
CrystalDecision s.Shared.Export Options

Dim myExportFile As String
Dim myExportOptions As CrystalDecision s.Shared.Export Options
Dim myDiskFileDesti nationOptions As
CrystalDecision s.Shared.DiskFi leDestinationOp tions

Try

Select Case UniqueFormat
Case FileNameFormats .SessionID
myExportFile = Session.Session ID.ToString
Case FileNameFormats .GUIDDashes
myExportFile = System.Guid.New Guid.ToString(" D")
Case FileNameFormats .GUIDNoDashes
myExportFile = System.Guid.New Guid.ToString(" N")
End Select

myExportFile = System.IO.Path. Combine(GetExpo rtRoot,
String.Format(" PDF_{0}.pdf", myExportFile))

myDiskFileDesti nationOptions = New
CrystalDecision s.Shared.DiskFi leDestinationOp tions
myDiskFileDesti nationOptions.D iskFileName = myExportFile

myExportOptions = ExportOptions

With myExportOptions
.DestinationOpt ions = myDiskFileDesti nationOptions
.ExportDestinat ionType = .ExportDestinat ionType.DiskFil e
.ExportFormatTy pe = .ExportFormatTy pe.PortableDocF ormat
End With

Catch ex As Exception

Dim exc As System.Applicat ionException
exc = New System.Applicat ionException("U nable to prepare export
options.", ex)
Throw exc

End Try

Return myExportOptions

End Function

Private Function GetExportRoot(B yVal FromApplication As Boolean) As
String

Dim strExportRoot As String

If FromApplication Then
Try
Application.Loc k()
strExportRoot = Application("Re portExportRoot" )
Catch ex As Exception
Dim exc As ApplicationExce ption
exc = New ApplicationExce ption("Unable to lock Web
Application for read.", ex)
Throw exc
Finally
Application.UnL ock()
End Try
Else
strExportRoot = Session("Report ExportRoot")
End If

Return strExportRoot

End Function

#End Region

#Region "Navigation Implementation"

Private Sub cmdPrint_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdPrint.Click

Response.ClearC ontent()
Response.ClearH eaders()
Response.Conten tType = "applicatio n/pdf"

Dim myExportFile As String = CType(Session.I tem("exportbest and"),
String)

Response.WriteF ile(myExportFil e)
Response.Flush( )
Response.Close( )

System.IO.File. Delete(myExport File)

End Sub

Private Sub cmdEerste_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdEerste.Click
crViewer.ShowFi rstPage()
End Sub

Private Sub cmdLaatste_Clic k(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdLaatste.Clic k
crViewer.ShowLa stPage()
End Sub

Private Sub cmdTerug_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdTerug.Click
crViewer.ShowPr eviousPage()
End Sub

Private Sub cmdVerder_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdVerder.Click
crViewer.ShowNe xtPage()
End Sub

Private Sub drpZoom_Selecte dIndexChanged(B yVal sender As Object, ByVal e
As System.EventArg s) Handles drpZoom.Selecte dIndexChanged
crViewer.Zoom(d rpZoom.Selected Item.Value)
End Sub

#End Region
End Class


"AMDRIT" <am****@hotmail .com> wrote in message
news:Op******** ******@TK2MSFTN GP09.phx.gbl...
Ok, first the isue you were having with the "Blue lines" is:

Private Function CreateParameter DiscreteValue(B yVal Value As Object) As
ParameterDiscre teValue()
--> Retun type is expecting an array of ParameterDiscre teValue

it should be

Private Function CreateParameter DiscreteValue(B yVal Value As Object) As
ParameterDiscre teValue
--> Retun type is expecting an single ParameterDiscre teValue

Second (Mostly because I was bored and also because I am still a novice),
I have altered your code yet again.
Private Enum FileNameFormats
SessionID = 0
GUIDDashes = 1
GUIDNoDashes = 2
End Enum

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()

Dim myReport As RapportAIRCOSto ringen
Dim myExportOptions As CrystalDecision s.Shared.Export Options

Try

Try
PrepareReport(m yReport)
Catch ex As Exception
Dim exc As ApplicationExce ption
exc = New ApplicationExce ption("Unable to prepare report.", ex)
Throw exc
End Try

Try
'exporteren to pdf
myExportOptions = GetExportOption s(FileNameForma ts.GUIDNoDashes ,
CType(myReport,
CrystalDecision s.CrystalReport s.Engine.Report Document).Expor tOptions)
myReport.Export ()

Catch ex As Exception
Dim exc As ApplicationExce ption
exc = New ApplicationExce ption("Unable to export report.", ex)
Throw exc
End Try

crViewer.Report Source = myReport

Session("export bestand") = CType(myExportO ptions.Destinat ionOptions,
CrystalDecision s.Shared.DiskFi leDestinationOp tions).DiskFile Name

Catch err As Exception
Response.Write( "<BR>")
Response.Write( err.Message.ToS tring)
End Try

End Sub

#Region "Page Implementation"

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Private Sub Page_Unload(ByV al sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Unload
Dim myExportFile As String = CType(Session.I tem("exportbest and"),
String)

System.IO.File. Delete(myExport File)
End Sub

#End Region

#Region "Report Setup"

Private Sub PrepareReport(B yVal myReport As
CrystalDecision s.CrystalReport s.Engine.Report Document)

Dim paramFields As ParameterFields
Dim paramField As ParameterField

Const SessionExecptio n As String = "Unable to read session objects."

Try

paramFields = New ParameterFields
Try
paramField = CreateParameter ("FiliaalKeuze" )

paramField.Curr entValues.Add(C reateParameterD iscreteValue(Ge tSessionValue(" DiscreteValue1" )))

paramField.Curr entValues.Add(C reateParameterD iscreteValue(Ge tSessionValue(" DiscreteValue1" )))
Catch ex As Exception
Dim exc As System.Applicat ionException
exc = New System.Applicat ionException(Se ssionExecption, ex)
Throw exc
End Try

myReport.SetPar ameterValue("Fi liaalKeuze", paramField)

Try
'Todo wrap in try
paramField = CreateParameter ("Periode")

paramField.Curr entValues.Add(C reateParameterR angeValue(GetSe ssionValue("Beg inPeriode"),
GetSessionValue ("EindPeriode") ))
Catch ex As Exception
Dim exc As System.Applicat ionException
exc = New System.Applicat ionException(Se ssionExecption, ex)
Throw exc
End Try

myReport.SetPar ameterValue("Pe riode", paramField)

Catch ex As Exception

Dim exc As System.Applicat ionException
exc = New System.Applicat ionException("U nable to set paramater
value.", ex)
Throw exc

End Try
End Sub

Private Function CreateParameter (ByVal ParameterName As String) As
ParameterField
Dim paramField As ParameterField

paramField = New ParameterField
paramField.Para meterFieldName = ParameterName

Return paramField

End Function

Private Function CreateParameter DiscreteValue(B yVal Value As Object) As
ParameterDiscre teValue()

Dim paramDiscreteVa lue As ParameterDiscre teValue
paramDiscreteVa lue = New ParameterDiscre teValue
paramDiscreteVa lue = Value

'Return paramDiscreteVa lue

End Function

Private Function CreateParameter RangeValue(ByVa l StartRange As Object,
ByVal EndRange As Object) As ParameterRangeV alue
Dim paramRangeValue As ParameterRangeV alue

paramRangeValue = New ParameterRangeV alue

paramRangeValue .StartValue = StartRange
paramRangeValue .EndValue = EndRange

Return paramRangeValue
End Function

#End Region

#Region "Report Export"

Private Function GetExportOption s(ByVal UniqueFormat As FileNameFormats ,
ByVal ExportOptions As CrystalDecision s.Shared.Export Options) As
CrystalDecision s.Shared.Export Options

Dim myExportFile As String
Dim myExportOptions As CrystalDecision s.Shared.Export Options
Dim myDiskFileDesti nationOptions As
CrystalDecision s.Shared.DiskFi leDestinationOp tions

Try

Select Case UniqueFormat
Case FileNameFormats .SessionID
myExportFile = Session.Session ID.ToString
Case FileNameFormats .GUIDDashes
myExportFile = System.Guid.New Guid.ToString(" D")
Case FileNameFormats .GUIDNoDashes
myExportFile = System.Guid.New Guid.ToString(" N")
End Select

myExportFile = System.IO.Path. Combine(GetExpo rtRoot,
String.Format(" PDF_{0}.pdf", myExportFile))

myDiskFileDesti nationOptions = New
CrystalDecision s.Shared.DiskFi leDestinationOp tions
myDiskFileDesti nationOptions.D iskFileName = myExportFile

myExportOptions = ExportOptions

With myExportOptions
.DestinationOpt ions = myDiskFileDesti nationOptions
.ExportDestinat ionType = .ExportDestinat ionType.DiskFil e
.ExportFormatTy pe = .ExportFormatTy pe.PortableDocF ormat
End With

Catch ex As Exception

Dim exc As System.Applicat ionException
exc = New System.Applicat ionException("U nable to prepare export
options.", ex)
Throw exc

End Try

Return myExportOptions

End Function

Private Function GetExportRoot(B yVal FromApplication As Boolean) As
String

Dim strExportRoot As String

If FromApplication Then
Try
Application.loc k()
strExportRoot = Application("Re portExportRoot" )
Catch ex As Exception
Dim exc As ApplicationExce ption
exc = New ApplicationExce ption("Unable to lock Web Application for
read.", ex)
Throw exc
Finally
Application.unl ock()
End Try
Else
strExportRoot = Session("Report ExportRoot")
End If

Return strExportRoot

End Function

#End Region

#Region "Navigation Implementation"

Private Sub cmdPrint_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdPrint.Click

Response.ClearC ontent()
Response.ClearH eaders()
Response.Conten tType = "applicatio n/pdf"

Dim myExportFile As String = CType(Session.I tem("exportbest and"),
String)

Response.WriteF ile(myExportFil e)
Response.Flush( )
Response.Close( )

System.IO.File. Delete(myExport File)

End Sub

Private Sub cmdEerste_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdEerste.Click
crViewer.ShowFi rstPage()
End Sub

Private Sub cmdLaatste_Clic k(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdLaatste.Clic k
crViewer.ShowLa stPage()
End Sub

Private Sub cmdTerug_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdTerug.Click
crViewer.ShowPr eviousPage()
End Sub

Private Sub cmdVerder_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdVerder.Click
crViewer.ShowNe xtPage()
End Sub

Private Sub drpZoom_Selecte dIndexChanged(B yVal sender As Object, ByVal e
As System.EventArg s) Handles drpZoom.Selecte dIndexChanged
crViewer.Zoom(d rpZoom.Selected Item.Value)
End Sub

#End Region
"Alison Givens" <in**@cross-it.nl> wrote in message
news:%2******** **********@TK2M SFTNGP14.phx.gb l...
Perhaps you could share your resulting code for comparison? Did you
see that I suggested the error in your code was

myReport.SetPar ameterValue("Fi liaalKeuze", discreteVal) 'You only call
this statement once (Effectively 2344) but you wanted two values.

To get the thing going, it would be enough for me at first to know how
to call the statement twice, so the other value is forwarded too.
(btw, these two values will be SessionObjects two, but I did it
hardcoded for testing)
Best would be ofcourse that I learn to do it 'clean' of course. I am a
real newbee at this.

Here is the rest of my code:

Imports CrystalDecision s.CrystalReport s.Engine
Imports CrystalDecision s.CrystalReport s.Engine.Report Document
Imports CrystalDecision s.Shared
Imports System.IO
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()

Dim myReport As RapportAIRCOSto ringen
Dim paramFields As ParameterFields
Dim paramField As ParameterField

Dim BeginPeriode As String
Dim EindPeriode As String

'Todo wrap everything in try
paramFields = New ParameterFields

Try
BeginPeriode = Request.QuerySt ring("BeginPeri ode")
EindPeriode = Request.QuerySt ring("EindPerio de")
Catch ex As Exception
Dim exCustom As ApplicationExce ption
exCustom = New ApplicationExce ption("Unable to parse Query
Paramaters.", ex)
Throw exCustom
End Try

'Todo wrap in try
paramField = CreateParameter ("FiliaalKeuze" )
paramField.Curr entValues.Add(C reateParameterD iscreteValue(20 44))
paramField.Curr entValues.Add(C reateParameterD iscreteValue(23 44))
myReport.SetPar ameterValue("Fi liaalKeuze", paramField)
'Todo wrap in try
paramField = CreateParameter ("Periode")

paramField.Curr entValues.Add(C reateParameterR angeValue(Begin Periode,
EindPeriode))
myReport.SetPar ameterValue("Pe riode", paramField)
crViewer.Report Source = myReport
'exporteren to pdf
Dim myExportOptions As CrystalDecision s.Shared.Export Options
Dim myDiskFileDesti nationOptions As
CrystalDecision s.Shared.DiskFi leDestinationOp tions
Dim myExportFile As String

myExportFile = "\\192.168.2.10 6\syn2sql$\PDF_ " &
Session.Session ID.ToString & ".pdf"
myDiskFileDesti nationOptions = New
CrystalDecision s.Shared.DiskFi leDestinationOp tions
myDiskFileDesti nationOptions.D iskFileName = myExportFile
myExportOptions = myReport.Export Options
With myExportOptions
.DestinationOpt ions = myDiskFileDesti nationOptions
.ExportDestinat ionType = .ExportDestinat ionType.DiskFil e
.ExportFormatTy pe = .ExportFormatTy pe.PortableDocF ormat
End With

Try
myReport.Export ()
Catch err As Exception
Response.Write( "<BR>")
Response.Write( err.Message.ToS tring)
End Try

Session("export bestand") = myExportFile
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
Private Sub cmdPrint_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdPrint.Click
Response.ClearC ontent()
Response.ClearH eaders()
Response.Conten tType = "applicatio n/pdf"
Dim myExportFile As String = CType(Session.I tem("exportbest and"),
String)

Response.WriteF ile(myExportFil e)
Response.Flush( )
Response.Close( )

System.IO.File. Delete(myExport File)
End Sub

Private Function CreateParameter (ByVal ParameterName As String) As
ParameterField( )
Dim paramField As ParameterField

paramField = New ParameterField
paramField.Para meterFieldName = ParameterName

'Return paramField

End Function

Private Function CreateParameter DiscreteValue(B yVal Value As Object)
As ParameterDiscre teValue()

Dim paramDiscreteVa lue As ParameterDiscre teValue
paramDiscreteVa lue = New ParameterDiscre teValue
paramDiscreteVa lue = Value

'Return paramDiscreteVa lue

End Function

Private Function CreateParameter RangeValue(ByVa l StartRange As
Object, ByVal EndRange As Object) As ParameterRangeV alue
Dim paramRangeValue As ParameterRangeV alue

paramRangeValue = New ParameterRangeV alue

paramRangeValue .StartValue = StartRange
paramRangeValue .EndValue = EndRange

Return paramRangeValue
End Function
Private Sub cmdEerste_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdEerste.Click
crViewer.ShowFi rstPage()
End Sub

Private Sub cmdLaatste_Clic k(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles cmdLaatste.Clic k
crViewer.ShowLa stPage()
End Sub

Private Sub cmdTerug_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdTerug.Click
crViewer.ShowPr eviousPage()
End Sub

Private Sub cmdVerder_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdVerder.Click
crViewer.ShowNe xtPage()
End Sub

Private Sub drpZoom_Selecte dIndexChanged(B yVal sender As Object,
ByVal e As System.EventArg s) Handles drpZoom.Selecte dIndexChanged
crViewer.Zoom(d rpZoom.Selected Item.Value)
End Sub
Private Sub Page_Unload(ByV al sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Unload
Dim myExportFile As String = CType(Session.I tem("exportbest and"),
String)

System.IO.File. Delete(myExport File)
End Sub
End Class



"Alison Givens" <in**@cross-it.nl> wrote in message
news:ee******** ******@TK2MSFTN GP09.phx.gbl...
> When I use your solution I get blue lines under the text like this
>
> paramField = CreateParamater ("FiliaalKeuze" )
> The text is:
> Value of type '1 dimensional array of
> CrystalDecision s.Shared.Parame terField' cannot be converted
> to 'Crystal.Decisi ons.Shared.Para meterField'
>
> Return paramField
> The text is:
> Value of type 'CrystalDecisio ns.Shared.Param eterField' cannot be
> converted
> to '1 dimensional array of Crystal.Decisio ns.Shared.Param eterField'
>
> Same for
> paramField = CreateParamater ("Periode")
> Return paramDiscreteVa lue
>
> Any idea what causes this?
>
> Alison
>
>
> "AMDRIT" <am****@hotmail .com> wrote in message
> news:ur******** *****@TK2MSFTNG P14.phx.gbl...
>> Wow, you do all that for Crystal Reports? What is
>> RapportAIRCOSto ringen?
>>
>>
>> Here is all I do for CR
>>
>> Dim x As CrystalDecision s.CrystalReport s.Engine.Report Document
>>
>> x.Load(sReportP ath) 'Reports are not embedded resources
>> x.SetParameterV alue("Paramater 1", Paramaters(1)) 'Dynamic
>> Paramaters
>> x.SetParameterV alue("Paramater 2", Paramaters(2))
>> x.SetDataSource (mydata) 'Strongly Typed Datasets
>>
>> Me.CrystalRepor tViewer1.Report Source = x
>> Me.CrystalRepor tViewer1.PrintR eport()
>>
>>
>> 'Now to answer your question about your code, hmm
>>
>> Ok, first
>>
>> Never --> Dim x as new object
>> 'This is silly, lazy and unprofessional. So if you are in
>> high school, keep the course.
>>
>>
>> Instead --> Dim x as object
>> Set x = new object
>> 'Reserve your space and contract
>> 'Then make use of it.
>>
>> I think this is your problem
>>
>> myReport.SetPar ameterValue("Fi liaalKeuze", discreteVal)
>>
>> Why are you setting the crView paramaters and the myReport
>> paramaters?
>> -->crViewer.Param eterFieldInfo = paramFields
>> -->myReport.SetPa rameterValue("P eriode", rangeVal)
>>
>> I think that myReport is the only think that needs to be set
>>
>>
>> I had to spent time reading your code to understand what you were
>> doing.
>>
>> Here is an attempt to clean it up.
>>
>> Private Sub TestIT()
>>
>> Dim myReport As RapportAIRCOSto ringen
>> Dim paramFields As ParameterFields
>> Dim paramField As ParameterField
>>
>> Dim BeginPeriode As String
>> Dim EindPeriode As String
>>
>> 'Todo wrap everything in try
>> paramFields = New ParameterFields
>>
>> Try
>> BeginPeriode = Request.QuerySt ring("BeginPeri ode")
>> EindPeriode = Request.QuerySt ring("EindPerio de")
>> Catch ex As Exception
>> Dim exCustom As ApplicationExce ption
>> exCustom = New ApplicationExce ption("Unable to parse Query
>> Paramaters.", ex)
>> Throw exCustom
>> End Try
>>
>> 'Todo wrap in try
>> paramField = CreateParamater ("FiliaalKeuze" )
>> paramField.Curr entValues.Add(C reateParameterD iscreteValue(20 44))
>> paramField.Curr entValues.Add(C reateParameterD iscreteValue(23 44))
>> myReport.SetPar ameterValue("Fi liaalKeuze", paramField)
>> 'paramFields.Ad d(paramField) --> Not needed
>>
>> 'Todo wrap in try
>> paramField = CreateParamater ("Periode")
>>
>> paramField.Curr entValues.Add(C reateParameterR angeValue(Begin Periode,
>> EindPeriode))
>> myReport.SetPar ameterValue("Pe riode", paramField)
>> 'paramFields.Ad d(paramField)--> Not needed
>>
>> 'Todo wrap in try, i don't think you need this
>> 'myReport.SetPa rameterValue("P eriode", rangeVal)
>> 'myReport.SetPa rameterValue("F iliaalKeuze", discreteVal)
>>
>> 'Todo, determine if we need this step; I don't think you do
>> 'crViewer.Param eterFieldInfo = paramFields
>>
>> crViewer.Report Source = myReport
>>
>> End Sub
>>
>> Private Function CreateParamater (ByVal ParamaterName As String) As
>> ParameterField
>> Dim paramField As ParameterField
>>
>> paramField = New ParameterField
>> paramField.Para meterFieldName = ParamaterName
>>
>> Return paramField
>>
>> End Function
>>
>> Private Function CreateParameter DiscreteValue(B yVal Value As Object)
>> As ParameterDiscre teValue
>>
>> Dim paramDiscreteVa lue As ParameterDiscre teValue
>> paramDiscreteVa lue = New ParameterDiscre teValue
>> paramDiscreteVa lue = Value
>>
>> Return paramDiscreteVa lue
>>
>> End Function
>>
>> Private Function CreateParameter RangeValue(ByVa l StartRange As
>> Object, ByVal EndRange As Object) As ParameterRangeV alue
>> Dim paramRangeValue As ParameterRangeV alue
>>
>> paramRangeValue = New ParameterRangeV alue
>>
>> paramRangeValue .StartValue = StartRange
>> paramRangeValue .EndValue = EndRange
>>
>> Return paramRangeValue
>> End Function
>>
>> "Alison Givens" <in**@cross-it.nl> wrote in message
>> news:eW******** *****@TK2MSFTNG P11.phx.gbl...
>>> ...... that nobody knows the answer.
>>> I can't imagine that I am the only one that uses parameters in CR.
>>>
>>> So, my question again:
>>>
>>> I have the following problem.
>>> (VB.NET 2003 with CR)
>>>
>>> I have a report with a multiple-value discrete value and a
>>> rangevalue.
>>> The report shows fine in the viewer, but when I hit the export to
>>> pdf
>>> button, it only uses one of two discrete values.
>>>
>>> This is the code:
>>> Dim BeginPeriode As String
>>> Dim EindPeriode As String
>>>
>>> BeginPeriode = Request.QuerySt ring("BeginPeri ode")
>>> EindPeriode = Request.QuerySt ring("EindPerio de")
>>>
>>> Dim myReport As New RapportAIRCOSto ringen
>>>
>>> Dim paramFields As New ParameterFields
>>> Dim paramField As New ParameterField
>>> Dim discreteVal As New ParameterDiscre teValue
>>> Dim rangeVal As New ParameterRangeV alue
>>>
>>> paramField.Para meterFieldName = "FiliaalKeu ze"
>>> discreteVal.Val ue = "2044"
>>> paramField.Curr entValues.Add(d iscreteVal)
>>>
>>> discreteVal = New ParameterDiscre teValue
>>> discreteVal.Val ue = "2344"
>>> paramField.Curr entValues.Add(d iscreteVal)
>>>
>>> paramFields.Add (paramField)
>>>
>>> paramField = New ParameterField
>>>
>>> paramField.Para meterFieldName = "Periode"
>>>
>>> rangeVal.StartV alue = BeginPeriode
>>> rangeVal.EndVal ue = EindPeriode
>>> paramField.Curr entValues.Add(r angeVal)
>>>
>>> paramFields.Add (paramField)
>>>
>>> crViewer.Parame terFieldInfo = paramFields
>>> myReport.SetPar ameterValue("Pe riode", rangeVal)
>>> myReport.SetPar ameterValue("Fi liaalKeuze", discreteVal)
>>> crViewer.Report Source = myReport
>>>
>>> As you can see I use myReport.SetPar ameterValue to feed the pdf.
>>> It goes wrong with the discrete value. It only sees the second value
>>> I
>>> entered and not the first.
>>> How can I get this going?
>>>
>>>
>>> Kind regards,
>>> Alison
>>>
>>>
>>>
>>>
>>
>>
>
>



Feb 21 '06 #8
Ok, to the next level.
I put the Add key in the web.config
It comes with an error as shown here.
Configuration Error
Description: An error occurred during the processing of a configuration file
required to service this request. Please review the specific error details
below and modify your configuration file appropriately.

Parser Error Message: Unrecognized element

Source Error:
Line 2: <configuratio n>
Line 3: <appSettings>
Line 4: <Add key="ReportExpo rtRoot" Value
="\\192.168.2.1 06\syn2sql$\PDF _" />
Line 5: </appSettings>
Line 6: <system.web>
I did all the other things aswell, as you described.
I have a question though about the GetSession.
Is the code allright, as I placed here?

Private Function GetSessionValue (ByVal KeyName As String) As Object
Return Session.Item(Ke yName)
End Function

I really appreciate your help, but since I am a real greenhorn, I hope you
are not going to fast for me.

Alison


"AMDRIT" <am****@hotmail .com> wrote in message
news:OY******** *****@TK2MSFTNG P15.phx.gbl...
Good morning,

I just realized you keep different hours than me. Please keep in mind
that all the code that I have submitted to you is wholly untested and
therefore the jist of what I was conveying should be taken into context.
I attempt to answer your direct question before going off onto a tangent.

1. You need a function named GetSessionValue
The signature would look like: GetSessionValue (KeyName as string) as
object and all it would do is return Session.Item(Ke yName)

2. Correct the line
myExportFile = System.IO.Path. Combine(GetExpo rtRoot,
String.Format(" PDF_{0}.pdf", myExportFile))
to
myExportFile = System.IO.Path. Combine(GetExpo rtRoot(false),
String.Format(" PDF_{0}.pdf", myExportFile))
or
myExportFile = System.IO.Path. Combine(GetExpo rtRoot(true),
String.Format(" PDF_{0}.pdf", myExportFile))

If you are to use the function GetExportRoot, then you must set up your
global.asax to set a global variable to hold ReportExportRoo t in
Application_OnS tart, and if you want each session to get a copy of that
value in the global.asax Session_OnStart , have it read the Application
variable.

The goal here is to store environmental setting information out of
compiled code. It's more work to set it up, but will not require you to
compile the application everytime you want to make a change.

ideal uses for the web config (DbConnection, ServerLocations , FileShares,
WebService URLs)

keep in mind though, each time you modify the webconfig, it spawns a new
instance of your application. Existing users (those already connected)
will not see your changes and will be orphaned from your intended
solution. Changes to the web config, once in production, should be treated
as a bug fix or enhancement that required replacement of binaries.

Example

In your web.config | appsettings section, create a key pair

<Add key="ReportExpo rtRoot" Value = "\\192.168.2.10 6\syn2sql$\PDF_ " />
for more information on appsettings see:
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003 FEB.1033/cpgenref/html/gngrfappsetting selement.htm

in your application's global.asax on Application_OnS tart
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003 FEB.1033/vbcon/html/vbconPageApplic ationContext.ht m
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003 FEB.1033/cpguide/html/cpcontheglobala saxfile.htm

sub application_ons tart()
Dim ReportExportRoo t as string
ReportExportRoo t =
System.Configur ation.Configura tionSettings.Ap pSettings("Repo rtExportRoot")
Application.Loc k
Application("Re portExportRoot" ) = ReportExportRoo t
Application.Unl ock
end sub

in you application's global.asax on Session_OnStart
sub Session_Onstart ()
Dim ReportExportRoo t as string
Application.Loc k
ReportExportRoo t = ctype(Applicati on("ReportExpor tRoot"),string)
Application.Unl ock
Session.item("R eportExportRoot ") = ReportExportRoo t
end sub

"Alison Givens" <in**@cross-it.nl> wrote in message
news:OT******** ******@TK2MSFTN GP11.phx.gbl...
I used the code as you suggested, but again I get blue underlines.
First with every GetSessionValue ,it has a blue underline:
Name GetSessionValue is not declared

and the other blue underline is GetExportRoot
myExportFile = System.IO.Path. Combine(GetExpo rtRoot,
String.Format(" PDF_{0}.pdf", myExportFile))
Says:Argument not specified for parameter 'FromApplicatio n' of
'Private Function GetExportRoot(F romApplication As Boolean) As String'.

I pasted the code again for your convenience.

Private Enum FileNameFormats
SessionID = 0
GUIDDashes = 1
GUIDNoDashes = 2
End Enum
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()
Dim myReport As RapportAIRCOSto ringen
Dim myExportOptions As CrystalDecision s.Shared.Export Options

Try

Try
PrepareReport(m yReport)
Catch ex As Exception
Dim exc As ApplicationExce ption
exc = New ApplicationExce ption("Unable to prepare
report.", ex)
Throw exc
End Try

Try
'exporteren to pdf
myExportOptions =
GetExportOption s(FileNameForma ts.GUIDNoDashes , CType(myReport,
CrystalDecision s.CrystalReport s.Engine.Report Document).Expor tOptions)
myReport.Export ()

Catch ex As Exception
Dim exc As ApplicationExce ption
exc = New ApplicationExce ption("Unable to export report.",
ex)
Throw exc
End Try

crViewer.Report Source = myReport

Session("export bestand") =
CType(myExportO ptions.Destinat ionOptions,
CrystalDecision s.Shared.DiskFi leDestinationOp tions).DiskFile Name

Catch err As Exception
Response.Write( "<BR>")
Response.Write( err.Message.ToS tring)
End Try


End Sub

#End Region

#Region "Page Implementation"

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Private Sub Page_Unload(ByV al sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Unload
Dim myExportFile As String = CType(Session.I tem("exportbest and"),
String)

System.IO.File. Delete(myExport File)
End Sub

#End Region

#Region "Report Setup"

Private Sub PrepareReport(B yVal myReport As
CrystalDecision s.CrystalReport s.Engine.Report Document)

Dim paramFields As ParameterFields
Dim paramField As ParameterField

Const SessionExecptio n As String = "Unable to read session
objects."

Try

paramFields = New ParameterFields
Try
paramField = CreateParameter ("FiliaalKeuze" )

paramField.Curr entValues.Add(C reateParameterD iscreteValue(Ge tSessionValue(" DiscreteValue1" )))

paramField.Curr entValues.Add(C reateParameterD iscreteValue(Ge tSessionValue(" DiscreteValue1" )))

Catch ex As Exception
Dim exc As System.Applicat ionException
exc = New System.Applicat ionException(Se ssionExecption,
ex)
Throw exc
End Try

myReport.SetPar ameterValue("Fi liaalKeuze", paramField)

Try
'Todo wrap in try
paramField = CreateParameter ("Periode")

paramField.Curr entValues.Add(C reateParameterR angeValue(GetSe ssionValue("Beg inPeriode"),
GetSessionValue ("EindPeriode") ))
Catch ex As Exception
Dim exc As System.Applicat ionException
exc = New System.Applicat ionException(Se ssionExecption,
ex)
Throw exc
End Try

myReport.SetPar ameterValue("Pe riode", paramField)

Catch ex As Exception

Dim exc As System.Applicat ionException
exc = New System.Applicat ionException("U nable to set
paramatervalue. ", ex)
Throw exc

End Try
End Sub

Private Function CreateParameter (ByVal ParameterName As String) As
ParameterField
Dim paramField As ParameterField

paramField = New ParameterField
paramField.Para meterFieldName = ParameterName

Return paramField

End Function

Private Function CreateParameter DiscreteValue(B yVal Value As Object)
As ParameterDiscre teValue

Dim paramDiscreteVa lue As ParameterDiscre teValue
paramDiscreteVa lue = New ParameterDiscre teValue
paramDiscreteVa lue = Value

Return paramDiscreteVa lue

End Function

Private Function CreateParameter RangeValue(ByVa l StartRange As Object,
ByVal EndRange As Object) As ParameterRangeV alue
Dim paramRangeValue As ParameterRangeV alue

paramRangeValue = New ParameterRangeV alue

paramRangeValue .StartValue = StartRange
paramRangeValue .EndValue = EndRange

Return paramRangeValue
End Function

#End Region

#Region "Report Export"

Private Function GetExportOption s(ByVal UniqueFormat As
FileNameFormats , ByVal ExportOptions As
CrystalDecision s.Shared.Export Options) As
CrystalDecision s.Shared.Export Options

Dim myExportFile As String
Dim myExportOptions As CrystalDecision s.Shared.Export Options
Dim myDiskFileDesti nationOptions As
CrystalDecision s.Shared.DiskFi leDestinationOp tions

Try

Select Case UniqueFormat
Case FileNameFormats .SessionID
myExportFile = Session.Session ID.ToString
Case FileNameFormats .GUIDDashes
myExportFile = System.Guid.New Guid.ToString(" D")
Case FileNameFormats .GUIDNoDashes
myExportFile = System.Guid.New Guid.ToString(" N")
End Select

myExportFile = System.IO.Path. Combine(GetExpo rtRoot,
String.Format(" PDF_{0}.pdf", myExportFile))

myDiskFileDesti nationOptions = New
CrystalDecision s.Shared.DiskFi leDestinationOp tions
myDiskFileDesti nationOptions.D iskFileName = myExportFile

myExportOptions = ExportOptions

With myExportOptions
.DestinationOpt ions = myDiskFileDesti nationOptions
.ExportDestinat ionType = .ExportDestinat ionType.DiskFil e
.ExportFormatTy pe = .ExportFormatTy pe.PortableDocF ormat
End With

Catch ex As Exception

Dim exc As System.Applicat ionException
exc = New System.Applicat ionException("U nable to prepare
export options.", ex)
Throw exc

End Try

Return myExportOptions

End Function

Private Function GetExportRoot(B yVal FromApplication As Boolean) As
String

Dim strExportRoot As String

If FromApplication Then
Try
Application.Loc k()
strExportRoot = Application("Re portExportRoot" )
Catch ex As Exception
Dim exc As ApplicationExce ption
exc = New ApplicationExce ption("Unable to lock Web
Application for read.", ex)
Throw exc
Finally
Application.UnL ock()
End Try
Else
strExportRoot = Session("Report ExportRoot")
End If

Return strExportRoot

End Function

#End Region

#Region "Navigation Implementation"

Private Sub cmdPrint_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdPrint.Click

Response.ClearC ontent()
Response.ClearH eaders()
Response.Conten tType = "applicatio n/pdf"

Dim myExportFile As String = CType(Session.I tem("exportbest and"),
String)

Response.WriteF ile(myExportFil e)
Response.Flush( )
Response.Close( )

System.IO.File. Delete(myExport File)

End Sub

Private Sub cmdEerste_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdEerste.Click
crViewer.ShowFi rstPage()
End Sub

Private Sub cmdLaatste_Clic k(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdLaatste.Clic k
crViewer.ShowLa stPage()
End Sub

Private Sub cmdTerug_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdTerug.Click
crViewer.ShowPr eviousPage()
End Sub

Private Sub cmdVerder_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdVerder.Click
crViewer.ShowNe xtPage()
End Sub

Private Sub drpZoom_Selecte dIndexChanged(B yVal sender As Object, ByVal e
As System.EventArg s) Handles drpZoom.Selecte dIndexChanged
crViewer.Zoom(d rpZoom.Selected Item.Value)
End Sub

#End Region
End Class


"AMDRIT" <am****@hotmail .com> wrote in message
news:Op******** ******@TK2MSFTN GP09.phx.gbl...
Ok, first the isue you were having with the "Blue lines" is:

Private Function CreateParameter DiscreteValue(B yVal Value As Object) As
ParameterDiscre teValue()
--> Retun type is expecting an array of ParameterDiscre teValue

it should be

Private Function CreateParameter DiscreteValue(B yVal Value As Object) As
ParameterDiscre teValue
--> Retun type is expecting an single ParameterDiscre teValue

Second (Mostly because I was bored and also because I am still a
novice), I have altered your code yet again.
Private Enum FileNameFormats
SessionID = 0
GUIDDashes = 1
GUIDNoDashes = 2
End Enum

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()

Dim myReport As RapportAIRCOSto ringen
Dim myExportOptions As CrystalDecision s.Shared.Export Options

Try

Try
PrepareReport(m yReport)
Catch ex As Exception
Dim exc As ApplicationExce ption
exc = New ApplicationExce ption("Unable to prepare report.", ex)
Throw exc
End Try

Try
'exporteren to pdf
myExportOptions = GetExportOption s(FileNameForma ts.GUIDNoDashes ,
CType(myReport,
CrystalDecision s.CrystalReport s.Engine.Report Document).Expor tOptions)
myReport.Export ()

Catch ex As Exception
Dim exc As ApplicationExce ption
exc = New ApplicationExce ption("Unable to export report.", ex)
Throw exc
End Try

crViewer.Report Source = myReport

Session("export bestand") =
CType(myExportO ptions.Destinat ionOptions,
CrystalDecision s.Shared.DiskFi leDestinationOp tions).DiskFile Name

Catch err As Exception
Response.Write( "<BR>")
Response.Write( err.Message.ToS tring)
End Try

End Sub

#Region "Page Implementation"

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Private Sub Page_Unload(ByV al sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Unload
Dim myExportFile As String = CType(Session.I tem("exportbest and"),
String)

System.IO.File. Delete(myExport File)
End Sub

#End Region

#Region "Report Setup"

Private Sub PrepareReport(B yVal myReport As
CrystalDecision s.CrystalReport s.Engine.Report Document)

Dim paramFields As ParameterFields
Dim paramField As ParameterField

Const SessionExecptio n As String = "Unable to read session objects."

Try

paramFields = New ParameterFields
Try
paramField = CreateParameter ("FiliaalKeuze" )

paramField.Curr entValues.Add(C reateParameterD iscreteValue(Ge tSessionValue(" DiscreteValue1" )))

paramField.Curr entValues.Add(C reateParameterD iscreteValue(Ge tSessionValue(" DiscreteValue1" )))
Catch ex As Exception
Dim exc As System.Applicat ionException
exc = New System.Applicat ionException(Se ssionExecption, ex)
Throw exc
End Try

myReport.SetPar ameterValue("Fi liaalKeuze", paramField)

Try
'Todo wrap in try
paramField = CreateParameter ("Periode")

paramField.Curr entValues.Add(C reateParameterR angeValue(GetSe ssionValue("Beg inPeriode"),
GetSessionValue ("EindPeriode") ))
Catch ex As Exception
Dim exc As System.Applicat ionException
exc = New System.Applicat ionException(Se ssionExecption, ex)
Throw exc
End Try

myReport.SetPar ameterValue("Pe riode", paramField)

Catch ex As Exception

Dim exc As System.Applicat ionException
exc = New System.Applicat ionException("U nable to set paramater
value.", ex)
Throw exc

End Try
End Sub

Private Function CreateParameter (ByVal ParameterName As String) As
ParameterField
Dim paramField As ParameterField

paramField = New ParameterField
paramField.Para meterFieldName = ParameterName

Return paramField

End Function

Private Function CreateParameter DiscreteValue(B yVal Value As Object) As
ParameterDiscre teValue()

Dim paramDiscreteVa lue As ParameterDiscre teValue
paramDiscreteVa lue = New ParameterDiscre teValue
paramDiscreteVa lue = Value

'Return paramDiscreteVa lue

End Function

Private Function CreateParameter RangeValue(ByVa l StartRange As Object,
ByVal EndRange As Object) As ParameterRangeV alue
Dim paramRangeValue As ParameterRangeV alue

paramRangeValue = New ParameterRangeV alue

paramRangeValue .StartValue = StartRange
paramRangeValue .EndValue = EndRange

Return paramRangeValue
End Function

#End Region

#Region "Report Export"

Private Function GetExportOption s(ByVal UniqueFormat As
FileNameFormats , ByVal ExportOptions As
CrystalDecision s.Shared.Export Options) As
CrystalDecision s.Shared.Export Options

Dim myExportFile As String
Dim myExportOptions As CrystalDecision s.Shared.Export Options
Dim myDiskFileDesti nationOptions As
CrystalDecision s.Shared.DiskFi leDestinationOp tions

Try

Select Case UniqueFormat
Case FileNameFormats .SessionID
myExportFile = Session.Session ID.ToString
Case FileNameFormats .GUIDDashes
myExportFile = System.Guid.New Guid.ToString(" D")
Case FileNameFormats .GUIDNoDashes
myExportFile = System.Guid.New Guid.ToString(" N")
End Select

myExportFile = System.IO.Path. Combine(GetExpo rtRoot,
String.Format(" PDF_{0}.pdf", myExportFile))

myDiskFileDesti nationOptions = New
CrystalDecision s.Shared.DiskFi leDestinationOp tions
myDiskFileDesti nationOptions.D iskFileName = myExportFile

myExportOptions = ExportOptions

With myExportOptions
.DestinationOpt ions = myDiskFileDesti nationOptions
.ExportDestinat ionType = .ExportDestinat ionType.DiskFil e
.ExportFormatTy pe = .ExportFormatTy pe.PortableDocF ormat
End With

Catch ex As Exception

Dim exc As System.Applicat ionException
exc = New System.Applicat ionException("U nable to prepare export
options.", ex)
Throw exc

End Try

Return myExportOptions

End Function

Private Function GetExportRoot(B yVal FromApplication As Boolean) As
String

Dim strExportRoot As String

If FromApplication Then
Try
Application.loc k()
strExportRoot = Application("Re portExportRoot" )
Catch ex As Exception
Dim exc As ApplicationExce ption
exc = New ApplicationExce ption("Unable to lock Web Application
for read.", ex)
Throw exc
Finally
Application.unl ock()
End Try
Else
strExportRoot = Session("Report ExportRoot")
End If

Return strExportRoot

End Function

#End Region

#Region "Navigation Implementation"

Private Sub cmdPrint_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdPrint.Click

Response.ClearC ontent()
Response.ClearH eaders()
Response.Conten tType = "applicatio n/pdf"

Dim myExportFile As String = CType(Session.I tem("exportbest and"),
String)

Response.WriteF ile(myExportFil e)
Response.Flush( )
Response.Close( )

System.IO.File. Delete(myExport File)

End Sub

Private Sub cmdEerste_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdEerste.Click
crViewer.ShowFi rstPage()
End Sub

Private Sub cmdLaatste_Clic k(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdLaatste.Clic k
crViewer.ShowLa stPage()
End Sub

Private Sub cmdTerug_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdTerug.Click
crViewer.ShowPr eviousPage()
End Sub

Private Sub cmdVerder_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdVerder.Click
crViewer.ShowNe xtPage()
End Sub

Private Sub drpZoom_Selecte dIndexChanged(B yVal sender As Object, ByVal
e As System.EventArg s) Handles drpZoom.Selecte dIndexChanged
crViewer.Zoom(d rpZoom.Selected Item.Value)
End Sub

#End Region
"Alison Givens" <in**@cross-it.nl> wrote in message
news:%2******** **********@TK2M SFTNGP14.phx.gb l...
> Perhaps you could share your resulting code for comparison? Did you
> see that I suggested the error in your code was
>
> myReport.SetPar ameterValue("Fi liaalKeuze", discreteVal) 'You only call
> this statement once (Effectively 2344) but you wanted two values.

To get the thing going, it would be enough for me at first to know how
to call the statement twice, so the other value is forwarded too.
(btw, these two values will be SessionObjects two, but I did it
hardcoded for testing)
Best would be ofcourse that I learn to do it 'clean' of course. I am a
real newbee at this.

Here is the rest of my code:

Imports CrystalDecision s.CrystalReport s.Engine
Imports CrystalDecision s.CrystalReport s.Engine.Report Document
Imports CrystalDecision s.Shared
Imports System.IO
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()

Dim myReport As RapportAIRCOSto ringen
Dim paramFields As ParameterFields
Dim paramField As ParameterField

Dim BeginPeriode As String
Dim EindPeriode As String

'Todo wrap everything in try
paramFields = New ParameterFields

Try
BeginPeriode = Request.QuerySt ring("BeginPeri ode")
EindPeriode = Request.QuerySt ring("EindPerio de")
Catch ex As Exception
Dim exCustom As ApplicationExce ption
exCustom = New ApplicationExce ption("Unable to parse Query
Paramaters.", ex)
Throw exCustom
End Try

'Todo wrap in try
paramField = CreateParameter ("FiliaalKeuze" )
paramField.Curr entValues.Add(C reateParameterD iscreteValue(20 44))
paramField.Curr entValues.Add(C reateParameterD iscreteValue(23 44))
myReport.SetPar ameterValue("Fi liaalKeuze", paramField)
'Todo wrap in try
paramField = CreateParameter ("Periode")

paramField.Curr entValues.Add(C reateParameterR angeValue(Begin Periode,
EindPeriode))
myReport.SetPar ameterValue("Pe riode", paramField)
crViewer.Report Source = myReport
'exporteren to pdf
Dim myExportOptions As CrystalDecision s.Shared.Export Options
Dim myDiskFileDesti nationOptions As
CrystalDecision s.Shared.DiskFi leDestinationOp tions
Dim myExportFile As String

myExportFile = "\\192.168.2.10 6\syn2sql$\PDF_ " &
Session.Session ID.ToString & ".pdf"
myDiskFileDesti nationOptions = New
CrystalDecision s.Shared.DiskFi leDestinationOp tions
myDiskFileDesti nationOptions.D iskFileName = myExportFile
myExportOptions = myReport.Export Options
With myExportOptions
.DestinationOpt ions = myDiskFileDesti nationOptions
.ExportDestinat ionType = .ExportDestinat ionType.DiskFil e
.ExportFormatTy pe = .ExportFormatTy pe.PortableDocF ormat
End With

Try
myReport.Export ()
Catch err As Exception
Response.Write( "<BR>")
Response.Write( err.Message.ToS tring)
End Try

Session("export bestand") = myExportFile
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
Private Sub cmdPrint_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdPrint.Click
Response.ClearC ontent()
Response.ClearH eaders()
Response.Conten tType = "applicatio n/pdf"
Dim myExportFile As String =
CType(Session.I tem("exportbest and"), String)

Response.WriteF ile(myExportFil e)
Response.Flush( )
Response.Close( )

System.IO.File. Delete(myExport File)
End Sub

Private Function CreateParameter (ByVal ParameterName As String) As
ParameterField( )
Dim paramField As ParameterField

paramField = New ParameterField
paramField.Para meterFieldName = ParameterName

'Return paramField

End Function

Private Function CreateParameter DiscreteValue(B yVal Value As Object)
As ParameterDiscre teValue()

Dim paramDiscreteVa lue As ParameterDiscre teValue
paramDiscreteVa lue = New ParameterDiscre teValue
paramDiscreteVa lue = Value

'Return paramDiscreteVa lue

End Function

Private Function CreateParameter RangeValue(ByVa l StartRange As
Object, ByVal EndRange As Object) As ParameterRangeV alue
Dim paramRangeValue As ParameterRangeV alue

paramRangeValue = New ParameterRangeV alue

paramRangeValue .StartValue = StartRange
paramRangeValue .EndValue = EndRange

Return paramRangeValue
End Function
Private Sub cmdEerste_Click (ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles cmdEerste.Click
crViewer.ShowFi rstPage()
End Sub

Private Sub cmdLaatste_Clic k(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles cmdLaatste.Clic k
crViewer.ShowLa stPage()
End Sub

Private Sub cmdTerug_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdTerug.Click
crViewer.ShowPr eviousPage()
End Sub

Private Sub cmdVerder_Click (ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles cmdVerder.Click
crViewer.ShowNe xtPage()
End Sub

Private Sub drpZoom_Selecte dIndexChanged(B yVal sender As Object,
ByVal e As System.EventArg s) Handles drpZoom.Selecte dIndexChanged
crViewer.Zoom(d rpZoom.Selected Item.Value)
End Sub
Private Sub Page_Unload(ByV al sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Unload
Dim myExportFile As String =
CType(Session.I tem("exportbest and"), String)

System.IO.File. Delete(myExport File)
End Sub
End Class


>
> "Alison Givens" <in**@cross-it.nl> wrote in message
> news:ee******** ******@TK2MSFTN GP09.phx.gbl...
>> When I use your solution I get blue lines under the text like this
>>
>> paramField = CreateParamater ("FiliaalKeuze" )
>> The text is:
>> Value of type '1 dimensional array of
>> CrystalDecision s.Shared.Parame terField' cannot be converted
>> to 'Crystal.Decisi ons.Shared.Para meterField'
>>
>> Return paramField
>> The text is:
>> Value of type 'CrystalDecisio ns.Shared.Param eterField' cannot be
>> converted
>> to '1 dimensional array of Crystal.Decisio ns.Shared.Param eterField'
>>
>> Same for
>> paramField = CreateParamater ("Periode")
>> Return paramDiscreteVa lue
>>
>> Any idea what causes this?
>>
>> Alison
>>
>>
>> "AMDRIT" <am****@hotmail .com> wrote in message
>> news:ur******** *****@TK2MSFTNG P14.phx.gbl...
>>> Wow, you do all that for Crystal Reports? What is
>>> RapportAIRCOSto ringen?
>>>
>>>
>>> Here is all I do for CR
>>>
>>> Dim x As CrystalDecision s.CrystalReport s.Engine.Report Document
>>>
>>> x.Load(sReportP ath) 'Reports are not embedded resources
>>> x.SetParameterV alue("Paramater 1", Paramaters(1)) 'Dynamic
>>> Paramaters
>>> x.SetParameterV alue("Paramater 2", Paramaters(2))
>>> x.SetDataSource (mydata) 'Strongly Typed Datasets
>>>
>>> Me.CrystalRepor tViewer1.Report Source = x
>>> Me.CrystalRepor tViewer1.PrintR eport()
>>>
>>>
>>> 'Now to answer your question about your code, hmm
>>>
>>> Ok, first
>>>
>>> Never --> Dim x as new object
>>> 'This is silly, lazy and unprofessional. So if you are in
>>> high school, keep the course.
>>>
>>>
>>> Instead --> Dim x as object
>>> Set x = new object
>>> 'Reserve your space and contract
>>> 'Then make use of it.
>>>
>>> I think this is your problem
>>>
>>> myReport.SetPar ameterValue("Fi liaalKeuze", discreteVal)
>>>
>>> Why are you setting the crView paramaters and the myReport
>>> paramaters?
>>> -->crViewer.Param eterFieldInfo = paramFields
>>> -->myReport.SetPa rameterValue("P eriode", rangeVal)
>>>
>>> I think that myReport is the only think that needs to be set
>>>
>>>
>>> I had to spent time reading your code to understand what you were
>>> doing.
>>>
>>> Here is an attempt to clean it up.
>>>
>>> Private Sub TestIT()
>>>
>>> Dim myReport As RapportAIRCOSto ringen
>>> Dim paramFields As ParameterFields
>>> Dim paramField As ParameterField
>>>
>>> Dim BeginPeriode As String
>>> Dim EindPeriode As String
>>>
>>> 'Todo wrap everything in try
>>> paramFields = New ParameterFields
>>>
>>> Try
>>> BeginPeriode = Request.QuerySt ring("BeginPeri ode")
>>> EindPeriode = Request.QuerySt ring("EindPerio de")
>>> Catch ex As Exception
>>> Dim exCustom As ApplicationExce ption
>>> exCustom = New ApplicationExce ption("Unable to parse Query
>>> Paramaters.", ex)
>>> Throw exCustom
>>> End Try
>>>
>>> 'Todo wrap in try
>>> paramField = CreateParamater ("FiliaalKeuze" )
>>> paramField.Curr entValues.Add(C reateParameterD iscreteValue(20 44))
>>> paramField.Curr entValues.Add(C reateParameterD iscreteValue(23 44))
>>> myReport.SetPar ameterValue("Fi liaalKeuze", paramField)
>>> 'paramFields.Ad d(paramField) --> Not needed
>>>
>>> 'Todo wrap in try
>>> paramField = CreateParamater ("Periode")
>>>
>>> paramField.Curr entValues.Add(C reateParameterR angeValue(Begin Periode,
>>> EindPeriode))
>>> myReport.SetPar ameterValue("Pe riode", paramField)
>>> 'paramFields.Ad d(paramField)--> Not needed
>>>
>>> 'Todo wrap in try, i don't think you need this
>>> 'myReport.SetPa rameterValue("P eriode", rangeVal)
>>> 'myReport.SetPa rameterValue("F iliaalKeuze", discreteVal)
>>>
>>> 'Todo, determine if we need this step; I don't think you do
>>> 'crViewer.Param eterFieldInfo = paramFields
>>>
>>> crViewer.Report Source = myReport
>>>
>>> End Sub
>>>
>>> Private Function CreateParamater (ByVal ParamaterName As String) As
>>> ParameterField
>>> Dim paramField As ParameterField
>>>
>>> paramField = New ParameterField
>>> paramField.Para meterFieldName = ParamaterName
>>>
>>> Return paramField
>>>
>>> End Function
>>>
>>> Private Function CreateParameter DiscreteValue(B yVal Value As
>>> Object) As ParameterDiscre teValue
>>>
>>> Dim paramDiscreteVa lue As ParameterDiscre teValue
>>> paramDiscreteVa lue = New ParameterDiscre teValue
>>> paramDiscreteVa lue = Value
>>>
>>> Return paramDiscreteVa lue
>>>
>>> End Function
>>>
>>> Private Function CreateParameter RangeValue(ByVa l StartRange As
>>> Object, ByVal EndRange As Object) As ParameterRangeV alue
>>> Dim paramRangeValue As ParameterRangeV alue
>>>
>>> paramRangeValue = New ParameterRangeV alue
>>>
>>> paramRangeValue .StartValue = StartRange
>>> paramRangeValue .EndValue = EndRange
>>>
>>> Return paramRangeValue
>>> End Function
>>>
>>> "Alison Givens" <in**@cross-it.nl> wrote in message
>>> news:eW******** *****@TK2MSFTNG P11.phx.gbl...
>>>> ...... that nobody knows the answer.
>>>> I can't imagine that I am the only one that uses parameters in CR.
>>>>
>>>> So, my question again:
>>>>
>>>> I have the following problem.
>>>> (VB.NET 2003 with CR)
>>>>
>>>> I have a report with a multiple-value discrete value and a
>>>> rangevalue.
>>>> The report shows fine in the viewer, but when I hit the export to
>>>> pdf
>>>> button, it only uses one of two discrete values.
>>>>
>>>> This is the code:
>>>> Dim BeginPeriode As String
>>>> Dim EindPeriode As String
>>>>
>>>> BeginPeriode = Request.QuerySt ring("BeginPeri ode")
>>>> EindPeriode = Request.QuerySt ring("EindPerio de")
>>>>
>>>> Dim myReport As New RapportAIRCOSto ringen
>>>>
>>>> Dim paramFields As New ParameterFields
>>>> Dim paramField As New ParameterField
>>>> Dim discreteVal As New ParameterDiscre teValue
>>>> Dim rangeVal As New ParameterRangeV alue
>>>>
>>>> paramField.Para meterFieldName = "FiliaalKeu ze"
>>>> discreteVal.Val ue = "2044"
>>>> paramField.Curr entValues.Add(d iscreteVal)
>>>>
>>>> discreteVal = New ParameterDiscre teValue
>>>> discreteVal.Val ue = "2344"
>>>> paramField.Curr entValues.Add(d iscreteVal)
>>>>
>>>> paramFields.Add (paramField)
>>>>
>>>> paramField = New ParameterField
>>>>
>>>> paramField.Para meterFieldName = "Periode"
>>>>
>>>> rangeVal.StartV alue = BeginPeriode
>>>> rangeVal.EndVal ue = EindPeriode
>>>> paramField.Curr entValues.Add(r angeVal)
>>>>
>>>> paramFields.Add (paramField)
>>>>
>>>> crViewer.Parame terFieldInfo = paramFields
>>>> myReport.SetPar ameterValue("Pe riode", rangeVal)
>>>> myReport.SetPar ameterValue("Fi liaalKeuze", discreteVal)
>>>> crViewer.Report Source = myReport
>>>>
>>>> As you can see I use myReport.SetPar ameterValue to feed the pdf.
>>>> It goes wrong with the discrete value. It only sees the second
>>>> value I
>>>> entered and not the first.
>>>> How can I get this going?
>>>>
>>>>
>>>> Kind regards,
>>>> Alison
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>



Feb 22 '06 #9
Perhaps web.config is case sensitive.

<configuratio n>
<appSettings>
<add key="ReportExpo rtRoot" value="\\192.16 8.2.106\syn2sql $\PDF_" />
</appSettings>
</configuration>

works for me, however notice add, key, and value are lower case. try that.

Your function is fine, perhaps you would like to spice it up a bit. (it is
really up to you and the amount of error handeling you would like.)
Private Function GetSessionValue (ByVal KeyName As String) As Object try Return Session.Item(Ke yName) catch ex as exception
dim exc as applicationexce ption
exc = new applicationexce ption(string.fo rmat("Unable to read value from
session:{0}",Ke yName),ex)
throw exc
end try End Function
there is a great series of webcasts on the MS Events site. The series was
presented by Joe Hummel, you should have a look at them. Here is a link to
get you started, the best part is that they are free.

http://www.microsoft.com/events/Even...taSvcParams%5e

or just go to msdn.microsoft. com/events, choose webcasts | Ondemand
webcasts. and then search for topics of interest. Many are .Net 1.1
related but the concepts carry forward to .Net 2.0.

If you have more questions, just drop a post here.

"Alison Givens" <in**@cross-it.nl> wrote in message
news:uV******** *****@TK2MSFTNG P15.phx.gbl... Ok, to the next level.
I put the Add key in the web.config
It comes with an error as shown here.
Configuration Error
Description: An error occurred during the processing of a configuration
file required to service this request. Please review the specific error
details below and modify your configuration file appropriately.

Parser Error Message: Unrecognized element

Source Error:
Line 2: <configuratio n>
Line 3: <appSettings>
Line 4: <Add key="ReportExpo rtRoot" Value
="\\192.168.2.1 06\syn2sql$\PDF _" />
Line 5: </appSettings>
Line 6: <system.web>
I did all the other things aswell, as you described.
I have a question though about the GetSession.
Is the code allright, as I placed here?

Private Function GetSessionValue (ByVal KeyName As String) As Object
Return Session.Item(Ke yName)
End Function

I really appreciate your help, but since I am a real greenhorn, I hope you
are not going to fast for me.

Alison


"AMDRIT" <am****@hotmail .com> wrote in message
news:OY******** *****@TK2MSFTNG P15.phx.gbl...
Good morning,

I just realized you keep different hours than me. Please keep in mind
that all the code that I have submitted to you is wholly untested and
therefore the jist of what I was conveying should be taken into context.
I attempt to answer your direct question before going off onto a tangent.

1. You need a function named GetSessionValue
The signature would look like: GetSessionValue (KeyName as string) as
object and all it would do is return Session.Item(Ke yName)

2. Correct the line
myExportFile = System.IO.Path. Combine(GetExpo rtRoot,
String.Format(" PDF_{0}.pdf", myExportFile))
to
myExportFile = System.IO.Path. Combine(GetExpo rtRoot(false),
String.Format(" PDF_{0}.pdf", myExportFile))
or
myExportFile = System.IO.Path. Combine(GetExpo rtRoot(true),
String.Format(" PDF_{0}.pdf", myExportFile))

If you are to use the function GetExportRoot, then you must set up your
global.asax to set a global variable to hold ReportExportRoo t in
Application_OnS tart, and if you want each session to get a copy of that
value in the global.asax Session_OnStart , have it read the Application
variable.

The goal here is to store environmental setting information out of
compiled code. It's more work to set it up, but will not require you to
compile the application everytime you want to make a change.

ideal uses for the web config (DbConnection, ServerLocations , FileShares,
WebService URLs)

keep in mind though, each time you modify the webconfig, it spawns a new
instance of your application. Existing users (those already connected)
will not see your changes and will be orphaned from your intended
solution. Changes to the web config, once in production, should be
treated as a bug fix or enhancement that required replacement of
binaries.

Example

In your web.config | appsettings section, create a key pair

<Add key="ReportExpo rtRoot" Value = "\\192.168.2.10 6\syn2sql$\PDF_ " />
for more information on appsettings see:
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003 FEB.1033/cpgenref/html/gngrfappsetting selement.htm

in your application's global.asax on Application_OnS tart
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003 FEB.1033/vbcon/html/vbconPageApplic ationContext.ht m
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003 FEB.1033/cpguide/html/cpcontheglobala saxfile.htm

sub application_ons tart()
Dim ReportExportRoo t as string
ReportExportRoo t =
System.Configur ation.Configura tionSettings.Ap pSettings("Repo rtExportRoot")
Application.Loc k
Application("Re portExportRoot" ) = ReportExportRoo t
Application.Unl ock
end sub

in you application's global.asax on Session_OnStart
sub Session_Onstart ()
Dim ReportExportRoo t as string
Application.Loc k
ReportExportRoo t = ctype(Applicati on("ReportExpor tRoot"),string)
Application.Unl ock
Session.item("R eportExportRoot ") = ReportExportRoo t
end sub

"Alison Givens" <in**@cross-it.nl> wrote in message
news:OT******** ******@TK2MSFTN GP11.phx.gbl...
I used the code as you suggested, but again I get blue underlines.
First with every GetSessionValue ,it has a blue underline:
Name GetSessionValue is not declared

and the other blue underline is GetExportRoot
myExportFile = System.IO.Path. Combine(GetExpo rtRoot,
String.Format(" PDF_{0}.pdf", myExportFile))
Says:Argument not specified for parameter 'FromApplicatio n' of
'Private Function GetExportRoot(F romApplication As Boolean) As String'.

I pasted the code again for your convenience.

Private Enum FileNameFormats
SessionID = 0
GUIDDashes = 1
GUIDNoDashes = 2
End Enum
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()
Dim myReport As RapportAIRCOSto ringen
Dim myExportOptions As CrystalDecision s.Shared.Export Options

Try

Try
PrepareReport(m yReport)
Catch ex As Exception
Dim exc As ApplicationExce ption
exc = New ApplicationExce ption("Unable to prepare
report.", ex)
Throw exc
End Try

Try
'exporteren to pdf
myExportOptions =
GetExportOption s(FileNameForma ts.GUIDNoDashes , CType(myReport,
CrystalDecision s.CrystalReport s.Engine.Report Document).Expor tOptions)
myReport.Export ()

Catch ex As Exception
Dim exc As ApplicationExce ption
exc = New ApplicationExce ption("Unable to export
report.", ex)
Throw exc
End Try

crViewer.Report Source = myReport

Session("export bestand") =
CType(myExportO ptions.Destinat ionOptions,
CrystalDecision s.Shared.DiskFi leDestinationOp tions).DiskFile Name

Catch err As Exception
Response.Write( "<BR>")
Response.Write( err.Message.ToS tring)
End Try


End Sub

#End Region

#Region "Page Implementation"

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Private Sub Page_Unload(ByV al sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Unload
Dim myExportFile As String = CType(Session.I tem("exportbest and"),
String)

System.IO.File. Delete(myExport File)
End Sub

#End Region

#Region "Report Setup"

Private Sub PrepareReport(B yVal myReport As
CrystalDecision s.CrystalReport s.Engine.Report Document)

Dim paramFields As ParameterFields
Dim paramField As ParameterField

Const SessionExecptio n As String = "Unable to read session
objects."

Try

paramFields = New ParameterFields
Try
paramField = CreateParameter ("FiliaalKeuze" )

paramField.Curr entValues.Add(C reateParameterD iscreteValue(Ge tSessionValue(" DiscreteValue1" )))

paramField.Curr entValues.Add(C reateParameterD iscreteValue(Ge tSessionValue(" DiscreteValue1" )))

Catch ex As Exception
Dim exc As System.Applicat ionException
exc = New System.Applicat ionException(Se ssionExecption,
ex)
Throw exc
End Try

myReport.SetPar ameterValue("Fi liaalKeuze", paramField)

Try
'Todo wrap in try
paramField = CreateParameter ("Periode")

paramField.Curr entValues.Add(C reateParameterR angeValue(GetSe ssionValue("Beg inPeriode"),
GetSessionValue ("EindPeriode") ))
Catch ex As Exception
Dim exc As System.Applicat ionException
exc = New System.Applicat ionException(Se ssionExecption,
ex)
Throw exc
End Try

myReport.SetPar ameterValue("Pe riode", paramField)

Catch ex As Exception

Dim exc As System.Applicat ionException
exc = New System.Applicat ionException("U nable to set
paramatervalue. ", ex)
Throw exc

End Try
End Sub

Private Function CreateParameter (ByVal ParameterName As String) As
ParameterField
Dim paramField As ParameterField

paramField = New ParameterField
paramField.Para meterFieldName = ParameterName

Return paramField

End Function

Private Function CreateParameter DiscreteValue(B yVal Value As Object)
As ParameterDiscre teValue

Dim paramDiscreteVa lue As ParameterDiscre teValue
paramDiscreteVa lue = New ParameterDiscre teValue
paramDiscreteVa lue = Value

Return paramDiscreteVa lue

End Function

Private Function CreateParameter RangeValue(ByVa l StartRange As
Object, ByVal EndRange As Object) As ParameterRangeV alue
Dim paramRangeValue As ParameterRangeV alue

paramRangeValue = New ParameterRangeV alue

paramRangeValue .StartValue = StartRange
paramRangeValue .EndValue = EndRange

Return paramRangeValue
End Function

#End Region

#Region "Report Export"

Private Function GetExportOption s(ByVal UniqueFormat As
FileNameFormats , ByVal ExportOptions As
CrystalDecision s.Shared.Export Options) As
CrystalDecision s.Shared.Export Options

Dim myExportFile As String
Dim myExportOptions As CrystalDecision s.Shared.Export Options
Dim myDiskFileDesti nationOptions As
CrystalDecision s.Shared.DiskFi leDestinationOp tions

Try

Select Case UniqueFormat
Case FileNameFormats .SessionID
myExportFile = Session.Session ID.ToString
Case FileNameFormats .GUIDDashes
myExportFile = System.Guid.New Guid.ToString(" D")
Case FileNameFormats .GUIDNoDashes
myExportFile = System.Guid.New Guid.ToString(" N")
End Select

myExportFile = System.IO.Path. Combine(GetExpo rtRoot,
String.Format(" PDF_{0}.pdf", myExportFile))

myDiskFileDesti nationOptions = New
CrystalDecision s.Shared.DiskFi leDestinationOp tions
myDiskFileDesti nationOptions.D iskFileName = myExportFile

myExportOptions = ExportOptions

With myExportOptions
.DestinationOpt ions = myDiskFileDesti nationOptions
.ExportDestinat ionType = .ExportDestinat ionType.DiskFil e
.ExportFormatTy pe = .ExportFormatTy pe.PortableDocF ormat
End With

Catch ex As Exception

Dim exc As System.Applicat ionException
exc = New System.Applicat ionException("U nable to prepare
export options.", ex)
Throw exc

End Try

Return myExportOptions

End Function

Private Function GetExportRoot(B yVal FromApplication As Boolean) As
String

Dim strExportRoot As String

If FromApplication Then
Try
Application.Loc k()
strExportRoot = Application("Re portExportRoot" )
Catch ex As Exception
Dim exc As ApplicationExce ption
exc = New ApplicationExce ption("Unable to lock Web
Application for read.", ex)
Throw exc
Finally
Application.UnL ock()
End Try
Else
strExportRoot = Session("Report ExportRoot")
End If

Return strExportRoot

End Function

#End Region

#Region "Navigation Implementation"

Private Sub cmdPrint_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdPrint.Click

Response.ClearC ontent()
Response.ClearH eaders()
Response.Conten tType = "applicatio n/pdf"

Dim myExportFile As String = CType(Session.I tem("exportbest and"),
String)

Response.WriteF ile(myExportFil e)
Response.Flush( )
Response.Close( )

System.IO.File. Delete(myExport File)

End Sub

Private Sub cmdEerste_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdEerste.Click
crViewer.ShowFi rstPage()
End Sub

Private Sub cmdLaatste_Clic k(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles cmdLaatste.Clic k
crViewer.ShowLa stPage()
End Sub

Private Sub cmdTerug_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdTerug.Click
crViewer.ShowPr eviousPage()
End Sub

Private Sub cmdVerder_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdVerder.Click
crViewer.ShowNe xtPage()
End Sub

Private Sub drpZoom_Selecte dIndexChanged(B yVal sender As Object, ByVal
e
As System.EventArg s) Handles drpZoom.Selecte dIndexChanged
crViewer.Zoom(d rpZoom.Selected Item.Value)
End Sub

#End Region
End Class


"AMDRIT" <am****@hotmail .com> wrote in message
news:Op******** ******@TK2MSFTN GP09.phx.gbl...
Ok, first the isue you were having with the "Blue lines" is:

Private Function CreateParameter DiscreteValue(B yVal Value As Object) As
ParameterDiscre teValue()
--> Retun type is expecting an array of ParameterDiscre teValue

it should be

Private Function CreateParameter DiscreteValue(B yVal Value As Object) As
ParameterDiscre teValue
--> Retun type is expecting an single ParameterDiscre teValue

Second (Mostly because I was bored and also because I am still a
novice), I have altered your code yet again.
Private Enum FileNameFormats
SessionID = 0
GUIDDashes = 1
GUIDNoDashes = 2
End Enum

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()

Dim myReport As RapportAIRCOSto ringen
Dim myExportOptions As CrystalDecision s.Shared.Export Options

Try

Try
PrepareReport(m yReport)
Catch ex As Exception
Dim exc As ApplicationExce ption
exc = New ApplicationExce ption("Unable to prepare report.", ex)
Throw exc
End Try

Try
'exporteren to pdf
myExportOptions = GetExportOption s(FileNameForma ts.GUIDNoDashes ,
CType(myReport,
CrystalDecision s.CrystalReport s.Engine.Report Document).Expor tOptions)
myReport.Export ()

Catch ex As Exception
Dim exc As ApplicationExce ption
exc = New ApplicationExce ption("Unable to export report.", ex)
Throw exc
End Try

crViewer.Report Source = myReport

Session("export bestand") =
CType(myExportO ptions.Destinat ionOptions,
CrystalDecision s.Shared.DiskFi leDestinationOp tions).DiskFile Name

Catch err As Exception
Response.Write( "<BR>")
Response.Write( err.Message.ToS tring)
End Try

End Sub

#Region "Page Implementation"

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

Private Sub Page_Unload(ByV al sender As Object, ByVal e As
System.EventArg s) Handles MyBase.Unload
Dim myExportFile As String = CType(Session.I tem("exportbest and"),
String)

System.IO.File. Delete(myExport File)
End Sub

#End Region

#Region "Report Setup"

Private Sub PrepareReport(B yVal myReport As
CrystalDecision s.CrystalReport s.Engine.Report Document)

Dim paramFields As ParameterFields
Dim paramField As ParameterField

Const SessionExecptio n As String = "Unable to read session objects."

Try

paramFields = New ParameterFields
Try
paramField = CreateParameter ("FiliaalKeuze" )

paramField.Curr entValues.Add(C reateParameterD iscreteValue(Ge tSessionValue(" DiscreteValue1" )))

paramField.Curr entValues.Add(C reateParameterD iscreteValue(Ge tSessionValue(" DiscreteValue1" )))
Catch ex As Exception
Dim exc As System.Applicat ionException
exc = New System.Applicat ionException(Se ssionExecption, ex)
Throw exc
End Try

myReport.SetPar ameterValue("Fi liaalKeuze", paramField)

Try
'Todo wrap in try
paramField = CreateParameter ("Periode")

paramField.Curr entValues.Add(C reateParameterR angeValue(GetSe ssionValue("Beg inPeriode"),
GetSessionValue ("EindPeriode") ))
Catch ex As Exception
Dim exc As System.Applicat ionException
exc = New System.Applicat ionException(Se ssionExecption, ex)
Throw exc
End Try

myReport.SetPar ameterValue("Pe riode", paramField)

Catch ex As Exception

Dim exc As System.Applicat ionException
exc = New System.Applicat ionException("U nable to set paramater
value.", ex)
Throw exc

End Try
End Sub

Private Function CreateParameter (ByVal ParameterName As String) As
ParameterField
Dim paramField As ParameterField

paramField = New ParameterField
paramField.Para meterFieldName = ParameterName

Return paramField

End Function

Private Function CreateParameter DiscreteValue(B yVal Value As Object)
As ParameterDiscre teValue()

Dim paramDiscreteVa lue As ParameterDiscre teValue
paramDiscreteVa lue = New ParameterDiscre teValue
paramDiscreteVa lue = Value

'Return paramDiscreteVa lue

End Function

Private Function CreateParameter RangeValue(ByVa l StartRange As Object,
ByVal EndRange As Object) As ParameterRangeV alue
Dim paramRangeValue As ParameterRangeV alue

paramRangeValue = New ParameterRangeV alue

paramRangeValue .StartValue = StartRange
paramRangeValue .EndValue = EndRange

Return paramRangeValue
End Function

#End Region

#Region "Report Export"

Private Function GetExportOption s(ByVal UniqueFormat As
FileNameFormats , ByVal ExportOptions As
CrystalDecision s.Shared.Export Options) As
CrystalDecision s.Shared.Export Options

Dim myExportFile As String
Dim myExportOptions As CrystalDecision s.Shared.Export Options
Dim myDiskFileDesti nationOptions As
CrystalDecision s.Shared.DiskFi leDestinationOp tions

Try

Select Case UniqueFormat
Case FileNameFormats .SessionID
myExportFile = Session.Session ID.ToString
Case FileNameFormats .GUIDDashes
myExportFile = System.Guid.New Guid.ToString(" D")
Case FileNameFormats .GUIDNoDashes
myExportFile = System.Guid.New Guid.ToString(" N")
End Select

myExportFile = System.IO.Path. Combine(GetExpo rtRoot,
String.Format(" PDF_{0}.pdf", myExportFile))

myDiskFileDesti nationOptions = New
CrystalDecision s.Shared.DiskFi leDestinationOp tions
myDiskFileDesti nationOptions.D iskFileName = myExportFile

myExportOptions = ExportOptions

With myExportOptions
.DestinationOpt ions = myDiskFileDesti nationOptions
.ExportDestinat ionType = .ExportDestinat ionType.DiskFil e
.ExportFormatTy pe = .ExportFormatTy pe.PortableDocF ormat
End With

Catch ex As Exception

Dim exc As System.Applicat ionException
exc = New System.Applicat ionException("U nable to prepare export
options.", ex)
Throw exc

End Try

Return myExportOptions

End Function

Private Function GetExportRoot(B yVal FromApplication As Boolean) As
String

Dim strExportRoot As String

If FromApplication Then
Try
Application.loc k()
strExportRoot = Application("Re portExportRoot" )
Catch ex As Exception
Dim exc As ApplicationExce ption
exc = New ApplicationExce ption("Unable to lock Web Application
for read.", ex)
Throw exc
Finally
Application.unl ock()
End Try
Else
strExportRoot = Session("Report ExportRoot")
End If

Return strExportRoot

End Function

#End Region

#Region "Navigation Implementation"

Private Sub cmdPrint_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdPrint.Click

Response.ClearC ontent()
Response.ClearH eaders()
Response.Conten tType = "applicatio n/pdf"

Dim myExportFile As String = CType(Session.I tem("exportbest and"),
String)

Response.WriteF ile(myExportFil e)
Response.Flush( )
Response.Close( )

System.IO.File. Delete(myExport File)

End Sub

Private Sub cmdEerste_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdEerste.Click
crViewer.ShowFi rstPage()
End Sub

Private Sub cmdLaatste_Clic k(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdLaatste.Clic k
crViewer.ShowLa stPage()
End Sub

Private Sub cmdTerug_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdTerug.Click
crViewer.ShowPr eviousPage()
End Sub

Private Sub cmdVerder_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles cmdVerder.Click
crViewer.ShowNe xtPage()
End Sub

Private Sub drpZoom_Selecte dIndexChanged(B yVal sender As Object, ByVal
e As System.EventArg s) Handles drpZoom.Selecte dIndexChanged
crViewer.Zoom(d rpZoom.Selected Item.Value)
End Sub

#End Region
"Alison Givens" <in**@cross-it.nl> wrote in message
news:%2******** **********@TK2M SFTNGP14.phx.gb l...
>> Perhaps you could share your resulting code for comparison? Did you
>> see that I suggested the error in your code was
>>
>> myReport.SetPar ameterValue("Fi liaalKeuze", discreteVal) 'You only
>> call this statement once (Effectively 2344) but you wanted two
>> values.
>
> To get the thing going, it would be enough for me at first to know how
> to call the statement twice, so the other value is forwarded too.
> (btw, these two values will be SessionObjects two, but I did it
> hardcoded for testing)
> Best would be ofcourse that I learn to do it 'clean' of course. I am a
> real newbee at this.
>
> Here is the rest of my code:
>
> Imports CrystalDecision s.CrystalReport s.Engine
> Imports CrystalDecision s.CrystalReport s.Engine.Report Document
> Imports CrystalDecision s.Shared
> Imports System.IO
>
>
> Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
> System.EventArg s) Handles MyBase.Init
> 'CODEGEN: This method call is required by the Web Form Designer
> 'Do not modify it using the code editor.
> InitializeCompo nent()
>
>
>
> Dim myReport As RapportAIRCOSto ringen
> Dim paramFields As ParameterFields
> Dim paramField As ParameterField
>
> Dim BeginPeriode As String
> Dim EindPeriode As String
>
> 'Todo wrap everything in try
> paramFields = New ParameterFields
>
> Try
> BeginPeriode = Request.QuerySt ring("BeginPeri ode")
> EindPeriode = Request.QuerySt ring("EindPerio de")
> Catch ex As Exception
> Dim exCustom As ApplicationExce ption
> exCustom = New ApplicationExce ption("Unable to parse Query
> Paramaters.", ex)
> Throw exCustom
> End Try
>
> 'Todo wrap in try
> paramField = CreateParameter ("FiliaalKeuze" )
>
> paramField.Curr entValues.Add(C reateParameterD iscreteValue(20 44))
>
> paramField.Curr entValues.Add(C reateParameterD iscreteValue(23 44))
> myReport.SetPar ameterValue("Fi liaalKeuze", paramField)
>
>
> 'Todo wrap in try
> paramField = CreateParameter ("Periode")
>
> paramField.Curr entValues.Add(C reateParameterR angeValue(Begin Periode,
> EindPeriode))
> myReport.SetPar ameterValue("Pe riode", paramField)
>
>
> crViewer.Report Source = myReport
>
>
> 'exporteren to pdf
> Dim myExportOptions As CrystalDecision s.Shared.Export Options
> Dim myDiskFileDesti nationOptions As
> CrystalDecision s.Shared.DiskFi leDestinationOp tions
> Dim myExportFile As String
>
>
>
> myExportFile = "\\192.168.2.10 6\syn2sql$\PDF_ " &
> Session.Session ID.ToString & ".pdf"
> myDiskFileDesti nationOptions = New
> CrystalDecision s.Shared.DiskFi leDestinationOp tions
> myDiskFileDesti nationOptions.D iskFileName = myExportFile
> myExportOptions = myReport.Export Options
> With myExportOptions
> .DestinationOpt ions = myDiskFileDesti nationOptions
> .ExportDestinat ionType = .ExportDestinat ionType.DiskFil e
> .ExportFormatTy pe = .ExportFormatTy pe.PortableDocF ormat
> End With
>
> Try
> myReport.Export ()
> Catch err As Exception
> Response.Write( "<BR>")
> Response.Write( err.Message.ToS tring)
> End Try
>
> Session("export bestand") = myExportFile
> End Sub
>
> #End Region
>
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArg s) Handles MyBase.Load
> 'Put user code to initialize the page here
> End Sub
> Private Sub cmdPrint_Click( ByVal sender As System.Object, ByVal e
> As System.EventArg s) Handles cmdPrint.Click
> Response.ClearC ontent()
> Response.ClearH eaders()
> Response.Conten tType = "applicatio n/pdf"
> Dim myExportFile As String =
> CType(Session.I tem("exportbest and"), String)
>
> Response.WriteF ile(myExportFil e)
> Response.Flush( )
> Response.Close( )
>
> System.IO.File. Delete(myExport File)
> End Sub
>
> Private Function CreateParameter (ByVal ParameterName As String) As
> ParameterField( )
> Dim paramField As ParameterField
>
> paramField = New ParameterField
> paramField.Para meterFieldName = ParameterName
>
> 'Return paramField
>
> End Function
>
> Private Function CreateParameter DiscreteValue(B yVal Value As
> Object) As ParameterDiscre teValue()
>
> Dim paramDiscreteVa lue As ParameterDiscre teValue
> paramDiscreteVa lue = New ParameterDiscre teValue
> paramDiscreteVa lue = Value
>
> 'Return paramDiscreteVa lue
>
> End Function
>
> Private Function CreateParameter RangeValue(ByVa l StartRange As
> Object, ByVal EndRange As Object) As ParameterRangeV alue
> Dim paramRangeValue As ParameterRangeV alue
>
> paramRangeValue = New ParameterRangeV alue
>
> paramRangeValue .StartValue = StartRange
> paramRangeValue .EndValue = EndRange
>
> Return paramRangeValue
> End Function
>
>
> Private Sub cmdEerste_Click (ByVal sender As System.Object, ByVal e
> As System.EventArg s) Handles cmdEerste.Click
> crViewer.ShowFi rstPage()
> End Sub
>
> Private Sub cmdLaatste_Clic k(ByVal sender As System.Object, ByVal e
> As System.EventArg s) Handles cmdLaatste.Clic k
> crViewer.ShowLa stPage()
> End Sub
>
> Private Sub cmdTerug_Click( ByVal sender As System.Object, ByVal e
> As System.EventArg s) Handles cmdTerug.Click
> crViewer.ShowPr eviousPage()
> End Sub
>
> Private Sub cmdVerder_Click (ByVal sender As System.Object, ByVal e
> As System.EventArg s) Handles cmdVerder.Click
> crViewer.ShowNe xtPage()
> End Sub
>
> Private Sub drpZoom_Selecte dIndexChanged(B yVal sender As Object,
> ByVal e As System.EventArg s) Handles drpZoom.Selecte dIndexChanged
> crViewer.Zoom(d rpZoom.Selected Item.Value)
> End Sub
> Private Sub Page_Unload(ByV al sender As Object, ByVal e As
> System.EventArg s) Handles MyBase.Unload
> Dim myExportFile As String =
> CType(Session.I tem("exportbest and"), String)
>
> System.IO.File. Delete(myExport File)
> End Sub
> End Class
>
>
>
>
>
>
>>
>> "Alison Givens" <in**@cross-it.nl> wrote in message
>> news:ee******** ******@TK2MSFTN GP09.phx.gbl...
>>> When I use your solution I get blue lines under the text like this
>>>
>>> paramField = CreateParamater ("FiliaalKeuze" )
>>> The text is:
>>> Value of type '1 dimensional array of
>>> CrystalDecision s.Shared.Parame terField' cannot be converted
>>> to 'Crystal.Decisi ons.Shared.Para meterField'
>>>
>>> Return paramField
>>> The text is:
>>> Value of type 'CrystalDecisio ns.Shared.Param eterField' cannot be
>>> converted
>>> to '1 dimensional array of Crystal.Decisio ns.Shared.Param eterField'
>>>
>>> Same for
>>> paramField = CreateParamater ("Periode")
>>> Return paramDiscreteVa lue
>>>
>>> Any idea what causes this?
>>>
>>> Alison
>>>
>>>
>>> "AMDRIT" <am****@hotmail .com> wrote in message
>>> news:ur******** *****@TK2MSFTNG P14.phx.gbl...
>>>> Wow, you do all that for Crystal Reports? What is
>>>> RapportAIRCOSto ringen?
>>>>
>>>>
>>>> Here is all I do for CR
>>>>
>>>> Dim x As CrystalDecision s.CrystalReport s.Engine.Report Document
>>>>
>>>> x.Load(sReportP ath) 'Reports are not embedded resources
>>>> x.SetParameterV alue("Paramater 1", Paramaters(1)) 'Dynamic
>>>> Paramaters
>>>> x.SetParameterV alue("Paramater 2", Paramaters(2))
>>>> x.SetDataSource (mydata) 'Strongly Typed Datasets
>>>>
>>>> Me.CrystalRepor tViewer1.Report Source = x
>>>> Me.CrystalRepor tViewer1.PrintR eport()
>>>>
>>>>
>>>> 'Now to answer your question about your code, hmm
>>>>
>>>> Ok, first
>>>>
>>>> Never --> Dim x as new object
>>>> 'This is silly, lazy and unprofessional. So if you are in
>>>> high school, keep the course.
>>>>
>>>>
>>>> Instead --> Dim x as object
>>>> Set x = new object
>>>> 'Reserve your space and contract
>>>> 'Then make use of it.
>>>>
>>>> I think this is your problem
>>>>
>>>> myReport.SetPar ameterValue("Fi liaalKeuze", discreteVal)
>>>>
>>>> Why are you setting the crView paramaters and the myReport
>>>> paramaters?
>>>> -->crViewer.Param eterFieldInfo = paramFields
>>>> -->myReport.SetPa rameterValue("P eriode", rangeVal)
>>>>
>>>> I think that myReport is the only think that needs to be set
>>>>
>>>>
>>>> I had to spent time reading your code to understand what you were
>>>> doing.
>>>>
>>>> Here is an attempt to clean it up.
>>>>
>>>> Private Sub TestIT()
>>>>
>>>> Dim myReport As RapportAIRCOSto ringen
>>>> Dim paramFields As ParameterFields
>>>> Dim paramField As ParameterField
>>>>
>>>> Dim BeginPeriode As String
>>>> Dim EindPeriode As String
>>>>
>>>> 'Todo wrap everything in try
>>>> paramFields = New ParameterFields
>>>>
>>>> Try
>>>> BeginPeriode = Request.QuerySt ring("BeginPeri ode")
>>>> EindPeriode = Request.QuerySt ring("EindPerio de")
>>>> Catch ex As Exception
>>>> Dim exCustom As ApplicationExce ption
>>>> exCustom = New ApplicationExce ption("Unable to parse Query
>>>> Paramaters.", ex)
>>>> Throw exCustom
>>>> End Try
>>>>
>>>> 'Todo wrap in try
>>>> paramField = CreateParamater ("FiliaalKeuze" )
>>>> paramField.Curr entValues.Add(C reateParameterD iscreteValue(20 44))
>>>> paramField.Curr entValues.Add(C reateParameterD iscreteValue(23 44))
>>>> myReport.SetPar ameterValue("Fi liaalKeuze", paramField)
>>>> 'paramFields.Ad d(paramField) --> Not needed
>>>>
>>>> 'Todo wrap in try
>>>> paramField = CreateParamater ("Periode")
>>>>
>>>> paramField.Curr entValues.Add(C reateParameterR angeValue(Begin Periode,
>>>> EindPeriode))
>>>> myReport.SetPar ameterValue("Pe riode", paramField)
>>>> 'paramFields.Ad d(paramField)--> Not needed
>>>>
>>>> 'Todo wrap in try, i don't think you need this
>>>> 'myReport.SetPa rameterValue("P eriode", rangeVal)
>>>> 'myReport.SetPa rameterValue("F iliaalKeuze", discreteVal)
>>>>
>>>> 'Todo, determine if we need this step; I don't think you do
>>>> 'crViewer.Param eterFieldInfo = paramFields
>>>>
>>>> crViewer.Report Source = myReport
>>>>
>>>> End Sub
>>>>
>>>> Private Function CreateParamater (ByVal ParamaterName As String) As
>>>> ParameterField
>>>> Dim paramField As ParameterField
>>>>
>>>> paramField = New ParameterField
>>>> paramField.Para meterFieldName = ParamaterName
>>>>
>>>> Return paramField
>>>>
>>>> End Function
>>>>
>>>> Private Function CreateParameter DiscreteValue(B yVal Value As
>>>> Object) As ParameterDiscre teValue
>>>>
>>>> Dim paramDiscreteVa lue As ParameterDiscre teValue
>>>> paramDiscreteVa lue = New ParameterDiscre teValue
>>>> paramDiscreteVa lue = Value
>>>>
>>>> Return paramDiscreteVa lue
>>>>
>>>> End Function
>>>>
>>>> Private Function CreateParameter RangeValue(ByVa l StartRange As
>>>> Object, ByVal EndRange As Object) As ParameterRangeV alue
>>>> Dim paramRangeValue As ParameterRangeV alue
>>>>
>>>> paramRangeValue = New ParameterRangeV alue
>>>>
>>>> paramRangeValue .StartValue = StartRange
>>>> paramRangeValue .EndValue = EndRange
>>>>
>>>> Return paramRangeValue
>>>> End Function
>>>>
>>>> "Alison Givens" <in**@cross-it.nl> wrote in message
>>>> news:eW******** *****@TK2MSFTNG P11.phx.gbl...
>>>>> ...... that nobody knows the answer.
>>>>> I can't imagine that I am the only one that uses parameters in CR.
>>>>>
>>>>> So, my question again:
>>>>>
>>>>> I have the following problem.
>>>>> (VB.NET 2003 with CR)
>>>>>
>>>>> I have a report with a multiple-value discrete value and a
>>>>> rangevalue.
>>>>> The report shows fine in the viewer, but when I hit the export to
>>>>> pdf
>>>>> button, it only uses one of two discrete values.
>>>>>
>>>>> This is the code:
>>>>> Dim BeginPeriode As String
>>>>> Dim EindPeriode As String
>>>>>
>>>>> BeginPeriode = Request.QuerySt ring("BeginPeri ode")
>>>>> EindPeriode = Request.QuerySt ring("EindPerio de")
>>>>>
>>>>> Dim myReport As New RapportAIRCOSto ringen
>>>>>
>>>>> Dim paramFields As New ParameterFields
>>>>> Dim paramField As New ParameterField
>>>>> Dim discreteVal As New ParameterDiscre teValue
>>>>> Dim rangeVal As New ParameterRangeV alue
>>>>>
>>>>> paramField.Para meterFieldName = "FiliaalKeu ze"
>>>>> discreteVal.Val ue = "2044"
>>>>> paramField.Curr entValues.Add(d iscreteVal)
>>>>>
>>>>> discreteVal = New ParameterDiscre teValue
>>>>> discreteVal.Val ue = "2344"
>>>>> paramField.Curr entValues.Add(d iscreteVal)
>>>>>
>>>>> paramFields.Add (paramField)
>>>>>
>>>>> paramField = New ParameterField
>>>>>
>>>>> paramField.Para meterFieldName = "Periode"
>>>>>
>>>>> rangeVal.StartV alue = BeginPeriode
>>>>> rangeVal.EndVal ue = EindPeriode
>>>>> paramField.Curr entValues.Add(r angeVal)
>>>>>
>>>>> paramFields.Add (paramField)
>>>>>
>>>>> crViewer.Parame terFieldInfo = paramFields
>>>>> myReport.SetPar ameterValue("Pe riode", rangeVal)
>>>>> myReport.SetPar ameterValue("Fi liaalKeuze", discreteVal)
>>>>> crViewer.Report Source = myReport
>>>>>
>>>>> As you can see I use myReport.SetPar ameterValue to feed the pdf.
>>>>> It goes wrong with the discrete value. It only sees the second
>>>>> value I
>>>>> entered and not the first.
>>>>> How can I get this going?
>>>>>
>>>>>
>>>>> Kind regards,
>>>>> Alison
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>



Feb 22 '06 #10

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

Similar topics

4
14466
by: Julia Briggs | last post by:
I am struggling to create a PHP function that would take a specified image (JPG, GIF or PNG) from a link, and resize it down to a thumbnail so it will always fit in a 200x250 space. I am hoping not to have it inserted or read from a database to do this function. Can it be done & someone please help me?
36
9456
by: rbt | last post by:
Say I have a list that has 3 letters in it: I want to print all the possible 4 digit combinations of those 3 letters: 4^3 = 64 aaaa
20
2475
by: CHIN | last post by:
Hi all.. here s my problem ( maybe some of you saw me on other groups, but i cant find the solution !! ) I have to upload a file to an external site, so, i made a .vbs file , that logins to the site, and then i have to select the file to upload.. i used sendkeys.. and i worked perfect.. BUT ... the computer must be locked for security ( obviusly ) reazons.. so..i think this probable solutions to unlock the computer and run the...
7
2343
by: Andrzej | last post by:
Is it possible to call a function which name is given by a string? Let assume that I created a program which call some functions for example void f1(void), void f2(void), void f3(void). After some time, I added new function void f4(void).
2
3800
by: Bhupesh Naik | last post by:
This is a query regarding my problem to make a spell and grammar check possible in text area of a web page. We have aspx pages which are used to construct letters. The browser based screens provide text area where the user can insert big chunks of text and submit it all to the server paragraph by paragraph. The requirement is to do a Spell Check AND Grammar Check in the text area. I did look at lot of possible third
1
6952
by: AAA | last post by:
hi, I'll explain fastly the program that i'm doing.. the computer asks me to enter the cardinal of a set X ( called "dimX" type integer)where X is a table of one dimension and then to fill it with numbers X; then the computer asks me how many subsets i have (nb_subset type (integer)) then,i have to enter for every sebset the card, and then to fill it, we'll have a two tables , one called cardY which contains nb_subset elements,and every...
25
2536
by: Piotr Nowak | last post by:
Hi, Say i have a server process which listens for some changes in database. When a change occurs i want to refresh my page in browser by notyfinig it. I do not want to refresh my page i.e. every 5 seconds, i just want to refresh it ONLY on server change just like desktop applications do. The problem is that refreshing evry n seconds has to much impact on my web server. The refresh action should be taken only when something
4
7673
by: RSH | last post by:
Okay my math skills aren't waht they used to be... With that being said what Im trying to do is create a matrix that given x number of columns, and y number of possible values i want to generate a two dimensional array of all possible combinations of values. A simple example: 2 - columns and 2 possible values would generate: 0 0
7
3351
by: Robert S. | last post by:
Searching some time now for documents on this but still did not find anything about it: Is it possible to replace the entry screen of MS Office Access 2007 - that one presenting that default 'templates' (with that big graphic buttons) - with some sort of own HTML-Page? I could imagine, that somehow it is possible to change this construction (hopefully not hardcoded in MS-Acc07), like it is possible to edit the 'Fluent Ribbon'? If so...
14
1996
by: bjorklund.emil | last post by:
Hello pythonistas. I'm a newbie to pretty much both programming and Python. I have a task that involves writing a test script for every possible combination of preference settings for a software I'm testing. I figured that this was something that a script could probably do pretty easily, given all the various possibilites. I started creating a dictionary of all the settings, where each key has a value that is a list of the possible...
0
8272
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8205
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8370
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8514
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6126
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4094
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2632
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 we have to send another system
1
1817
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1516
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.