Home All Groups Group Topic Archive Search About

How is it possible ...

Author
16 Feb 2006 9:21 AM
Alison Givens
....... 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.QueryString("BeginPeriode")
EindPeriode = Request.QueryString("EindPeriode")

Dim myReport As New RapportAIRCOStoringen

Dim paramFields As New ParameterFields
Dim paramField As New ParameterField
Dim discreteVal As New ParameterDiscreteValue
Dim rangeVal As New ParameterRangeValue

paramField.ParameterFieldName = "FiliaalKeuze"
discreteVal.Value = "2044"
paramField.CurrentValues.Add(discreteVal)

discreteVal = New ParameterDiscreteValue
discreteVal.Value = "2344"
paramField.CurrentValues.Add(discreteVal)

paramFields.Add(paramField)

paramField = New ParameterField

paramField.ParameterFieldName = "Periode"

rangeVal.StartValue = BeginPeriode
rangeVal.EndValue = EindPeriode
paramField.CurrentValues.Add(rangeVal)

paramFields.Add(paramField)

crViewer.ParameterFieldInfo = paramFields
myReport.SetParameterValue("Periode", rangeVal)
myReport.SetParameterValue("FiliaalKeuze", discreteVal)
crViewer.ReportSource = myReport

As you can see I use myReport.SetParameterValue 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

Author
16 Feb 2006 11:04 PM
AMDRIT
Wow, you do all that for Crystal Reports?  What is RapportAIRCOStoringen?


Here is all I do for CR

Dim x As CrystalDecisions.CrystalReports.Engine.ReportDocument

x.Load(sReportPath)
'Reports are not embedded resources
x.SetParameterValue("Paramater1", Paramaters(1))      'Dynamic Paramaters
x.SetParameterValue("Paramater2", Paramaters(2))
x.SetDataSource(mydata)                                            'Strongly
Typed Datasets

Me.CrystalReportViewer1.ReportSource = x
Me.CrystalReportViewer1.PrintReport()


'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.SetParameterValue("FiliaalKeuze", discreteVal)

Why are you setting the crView paramaters and the myReport paramaters?
  -->crViewer.ParameterFieldInfo = paramFields
  -->myReport.SetParameterValue("Periode", 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 RapportAIRCOStoringen
    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.QueryString("BeginPeriode")
      EindPeriode = Request.QueryString("EindPeriode")
    Catch ex As Exception
      Dim exCustom As ApplicationException
      exCustom = New ApplicationException("Unable to parse Query
Paramaters.", ex)
      Throw exCustom
    End Try

    'Todo wrap in try
    paramField = CreateParamater("FiliaalKeuze")
    paramField.CurrentValues.Add(CreateParameterDiscreteValue(2044))
    paramField.CurrentValues.Add(CreateParameterDiscreteValue(2344))
    myReport.SetParameterValue("FiliaalKeuze", paramField)
    'paramFields.Add(paramField) --> Not needed

    'Todo wrap in try
    paramField = CreateParamater("Periode")
    paramField.CurrentValues.Add(CreateParameterRangeValue(BeginPeriode,
EindPeriode))
    myReport.SetParameterValue("Periode", paramField)
    'paramFields.Add(paramField)--> Not needed

    'Todo wrap in try, i don't think you need this
    'myReport.SetParameterValue("Periode", rangeVal)
    'myReport.SetParameterValue("FiliaalKeuze", discreteVal)

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

    crViewer.ReportSource = myReport

  End Sub

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

    paramField = New ParameterField
    paramField.ParameterFieldName = ParamaterName

    Return paramField

  End Function

  Private Function CreateParameterDiscreteValue(ByVal Value As Object) As
ParameterDiscreteValue

    Dim paramDiscreteValue As ParameterDiscreteValue
    paramDiscreteValue = New ParameterDiscreteValue
    paramDiscreteValue = Value

    Return paramDiscreteValue

  End Function

  Private Function CreateParameterRangeValue(ByVal StartRange As Object,
ByVal EndRange As Object) As ParameterRangeValue
    Dim paramRangeValue As ParameterRangeValue

    paramRangeValue = New ParameterRangeValue

    paramRangeValue.StartValue = StartRange
    paramRangeValue.EndValue = EndRange

    Return paramRangeValue
  End Function

Show quoteHide quote
"Alison Givens" <i***@cross-it.nl> wrote in message
news:eW4b66tMGHA.668@TK2MSFTNGP11.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.QueryString("BeginPeriode")
> EindPeriode = Request.QueryString("EindPeriode")
>
> Dim myReport As New RapportAIRCOStoringen
>
> Dim paramFields As New ParameterFields
> Dim paramField As New ParameterField
> Dim discreteVal As New ParameterDiscreteValue
> Dim rangeVal As New ParameterRangeValue
>
> paramField.ParameterFieldName = "FiliaalKeuze"
> discreteVal.Value = "2044"
> paramField.CurrentValues.Add(discreteVal)
>
> discreteVal = New ParameterDiscreteValue
> discreteVal.Value = "2344"
> paramField.CurrentValues.Add(discreteVal)
>
> paramFields.Add(paramField)
>
> paramField = New ParameterField
>
> paramField.ParameterFieldName = "Periode"
>
> rangeVal.StartValue = BeginPeriode
> rangeVal.EndValue = EindPeriode
> paramField.CurrentValues.Add(rangeVal)
>
> paramFields.Add(paramField)
>
> crViewer.ParameterFieldInfo = paramFields
> myReport.SetParameterValue("Periode", rangeVal)
> myReport.SetParameterValue("FiliaalKeuze", discreteVal)
> crViewer.ReportSource = myReport
>
> As you can see I use myReport.SetParameterValue 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
>
>
>
>
Author
20 Feb 2006 9:36 AM
Alison Givens
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
CrystalDecisions.Shared.ParameterField' cannot be converted
to 'Crystal.Decisions.Shared.ParameterField'

Return paramField
The text is:
Value of type 'CrystalDecisions.Shared.ParameterField' cannot be converted
to '1 dimensional array of Crystal.Decisions.Shared.ParameterField'

Same for
paramField = CreateParamater("Periode")
Return paramDiscreteValue

Any idea what causes this?

Alison


Show quoteHide quote
"AMDRIT" <amd***@hotmail.com> wrote in message
news:urCzE10MGHA.720@TK2MSFTNGP14.phx.gbl...
> Wow, you do all that for Crystal Reports?  What is RapportAIRCOStoringen?
>
>
> Here is all I do for CR
>
> Dim x As CrystalDecisions.CrystalReports.Engine.ReportDocument
>
> x.Load(sReportPath) 'Reports are not embedded resources
> x.SetParameterValue("Paramater1", Paramaters(1))      'Dynamic Paramaters
> x.SetParameterValue("Paramater2", Paramaters(2))
> x.SetDataSource(mydata)
> 'Strongly Typed Datasets
>
> Me.CrystalReportViewer1.ReportSource = x
> Me.CrystalReportViewer1.PrintReport()
>
>
> '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.SetParameterValue("FiliaalKeuze", discreteVal)
>
> Why are you setting the crView paramaters and the myReport paramaters?
>  -->crViewer.ParameterFieldInfo = paramFields
>  -->myReport.SetParameterValue("Periode", 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 RapportAIRCOStoringen
>    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.QueryString("BeginPeriode")
>      EindPeriode = Request.QueryString("EindPeriode")
>    Catch ex As Exception
>      Dim exCustom As ApplicationException
>      exCustom = New ApplicationException("Unable to parse Query
> Paramaters.", ex)
>      Throw exCustom
>    End Try
>
>    'Todo wrap in try
>    paramField = CreateParamater("FiliaalKeuze")
>    paramField.CurrentValues.Add(CreateParameterDiscreteValue(2044))
>    paramField.CurrentValues.Add(CreateParameterDiscreteValue(2344))
>    myReport.SetParameterValue("FiliaalKeuze", paramField)
>    'paramFields.Add(paramField) --> Not needed
>
>    'Todo wrap in try
>    paramField = CreateParamater("Periode")
>    paramField.CurrentValues.Add(CreateParameterRangeValue(BeginPeriode,
> EindPeriode))
>    myReport.SetParameterValue("Periode", paramField)
>    'paramFields.Add(paramField)--> Not needed
>
>    'Todo wrap in try, i don't think you need this
>    'myReport.SetParameterValue("Periode", rangeVal)
>    'myReport.SetParameterValue("FiliaalKeuze", discreteVal)
>
>    'Todo, determine if we need this step; I don't think you do
>    'crViewer.ParameterFieldInfo = paramFields
>
>    crViewer.ReportSource = myReport
>
>  End Sub
>
>  Private Function CreateParamater(ByVal ParamaterName As String) As
> ParameterField
>    Dim paramField As ParameterField
>
>    paramField = New ParameterField
>    paramField.ParameterFieldName = ParamaterName
>
>    Return paramField
>
>  End Function
>
>  Private Function CreateParameterDiscreteValue(ByVal Value As Object) As
> ParameterDiscreteValue
>
>    Dim paramDiscreteValue As ParameterDiscreteValue
>    paramDiscreteValue = New ParameterDiscreteValue
>    paramDiscreteValue = Value
>
>    Return paramDiscreteValue
>
>  End Function
>
>  Private Function CreateParameterRangeValue(ByVal StartRange As Object,
> ByVal EndRange As Object) As ParameterRangeValue
>    Dim paramRangeValue As ParameterRangeValue
>
>    paramRangeValue = New ParameterRangeValue
>
>    paramRangeValue.StartValue = StartRange
>    paramRangeValue.EndValue = EndRange
>
>    Return paramRangeValue
>  End Function
>
> "Alison Givens" <i***@cross-it.nl> wrote in message
> news:eW4b66tMGHA.668@TK2MSFTNGP11.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.QueryString("BeginPeriode")
>> EindPeriode = Request.QueryString("EindPeriode")
>>
>> Dim myReport As New RapportAIRCOStoringen
>>
>> Dim paramFields As New ParameterFields
>> Dim paramField As New ParameterField
>> Dim discreteVal As New ParameterDiscreteValue
>> Dim rangeVal As New ParameterRangeValue
>>
>> paramField.ParameterFieldName = "FiliaalKeuze"
>> discreteVal.Value = "2044"
>> paramField.CurrentValues.Add(discreteVal)
>>
>> discreteVal = New ParameterDiscreteValue
>> discreteVal.Value = "2344"
>> paramField.CurrentValues.Add(discreteVal)
>>
>> paramFields.Add(paramField)
>>
>> paramField = New ParameterField
>>
>> paramField.ParameterFieldName = "Periode"
>>
>> rangeVal.StartValue = BeginPeriode
>> rangeVal.EndValue = EindPeriode
>> paramField.CurrentValues.Add(rangeVal)
>>
>> paramFields.Add(paramField)
>>
>> crViewer.ParameterFieldInfo = paramFields
>> myReport.SetParameterValue("Periode", rangeVal)
>> myReport.SetParameterValue("FiliaalKeuze", discreteVal)
>> crViewer.ReportSource = myReport
>>
>> As you can see I use myReport.SetParameterValue 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
>>
>>
>>
>>
>
>
Author
20 Feb 2006 4:11 PM
AMDRIT
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.ParameterFieldName = "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.ParameterFieldName = 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.SetParameterValue("FiliaalKeuze", discreteVal) 'You only call this
statement once (Effectively 2344) but you wanted two values.


Show quoteHide quote
"Alison Givens" <i***@cross-it.nl> wrote in message
news:eeEqNEgNGHA.1288@TK2MSFTNGP09.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
> CrystalDecisions.Shared.ParameterField' cannot be converted
> to 'Crystal.Decisions.Shared.ParameterField'
>
> Return paramField
> The text is:
> Value of type 'CrystalDecisions.Shared.ParameterField' cannot be converted
> to '1 dimensional array of Crystal.Decisions.Shared.ParameterField'
>
> Same for
> paramField = CreateParamater("Periode")
> Return paramDiscreteValue
>
> Any idea what causes this?
>
> Alison
>
>
> "AMDRIT" <amd***@hotmail.com> wrote in message
> news:urCzE10MGHA.720@TK2MSFTNGP14.phx.gbl...
>> Wow, you do all that for Crystal Reports?  What is RapportAIRCOStoringen?
>>
>>
>> Here is all I do for CR
>>
>> Dim x As CrystalDecisions.CrystalReports.Engine.ReportDocument
>>
>> x.Load(sReportPath) 'Reports are not embedded resources
>> x.SetParameterValue("Paramater1", Paramaters(1))      'Dynamic Paramaters
>> x.SetParameterValue("Paramater2", Paramaters(2))
>> x.SetDataSource(mydata) 'Strongly Typed Datasets
>>
>> Me.CrystalReportViewer1.ReportSource = x
>> Me.CrystalReportViewer1.PrintReport()
>>
>>
>> '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.SetParameterValue("FiliaalKeuze", discreteVal)
>>
>> Why are you setting the crView paramaters and the myReport paramaters?
>>  -->crViewer.ParameterFieldInfo = paramFields
>>  -->myReport.SetParameterValue("Periode", 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 RapportAIRCOStoringen
>>    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.QueryString("BeginPeriode")
>>      EindPeriode = Request.QueryString("EindPeriode")
>>    Catch ex As Exception
>>      Dim exCustom As ApplicationException
>>      exCustom = New ApplicationException("Unable to parse Query
>> Paramaters.", ex)
>>      Throw exCustom
>>    End Try
>>
>>    'Todo wrap in try
>>    paramField = CreateParamater("FiliaalKeuze")
>>    paramField.CurrentValues.Add(CreateParameterDiscreteValue(2044))
>>    paramField.CurrentValues.Add(CreateParameterDiscreteValue(2344))
>>    myReport.SetParameterValue("FiliaalKeuze", paramField)
>>    'paramFields.Add(paramField) --> Not needed
>>
>>    'Todo wrap in try
>>    paramField = CreateParamater("Periode")
>>    paramField.CurrentValues.Add(CreateParameterRangeValue(BeginPeriode,
>> EindPeriode))
>>    myReport.SetParameterValue("Periode", paramField)
>>    'paramFields.Add(paramField)--> Not needed
>>
>>    'Todo wrap in try, i don't think you need this
>>    'myReport.SetParameterValue("Periode", rangeVal)
>>    'myReport.SetParameterValue("FiliaalKeuze", discreteVal)
>>
>>    'Todo, determine if we need this step; I don't think you do
>>    'crViewer.ParameterFieldInfo = paramFields
>>
>>    crViewer.ReportSource = myReport
>>
>>  End Sub
>>
>>  Private Function CreateParamater(ByVal ParamaterName As String) As
>> ParameterField
>>    Dim paramField As ParameterField
>>
>>    paramField = New ParameterField
>>    paramField.ParameterFieldName = ParamaterName
>>
>>    Return paramField
>>
>>  End Function
>>
>>  Private Function CreateParameterDiscreteValue(ByVal Value As Object) As
>> ParameterDiscreteValue
>>
>>    Dim paramDiscreteValue As ParameterDiscreteValue
>>    paramDiscreteValue = New ParameterDiscreteValue
>>    paramDiscreteValue = Value
>>
>>    Return paramDiscreteValue
>>
>>  End Function
>>
>>  Private Function CreateParameterRangeValue(ByVal StartRange As Object,
>> ByVal EndRange As Object) As ParameterRangeValue
>>    Dim paramRangeValue As ParameterRangeValue
>>
>>    paramRangeValue = New ParameterRangeValue
>>
>>    paramRangeValue.StartValue = StartRange
>>    paramRangeValue.EndValue = EndRange
>>
>>    Return paramRangeValue
>>  End Function
>>
>> "Alison Givens" <i***@cross-it.nl> wrote in message
>> news:eW4b66tMGHA.668@TK2MSFTNGP11.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.QueryString("BeginPeriode")
>>> EindPeriode = Request.QueryString("EindPeriode")
>>>
>>> Dim myReport As New RapportAIRCOStoringen
>>>
>>> Dim paramFields As New ParameterFields
>>> Dim paramField As New ParameterField
>>> Dim discreteVal As New ParameterDiscreteValue
>>> Dim rangeVal As New ParameterRangeValue
>>>
>>> paramField.ParameterFieldName = "FiliaalKeuze"
>>> discreteVal.Value = "2044"
>>> paramField.CurrentValues.Add(discreteVal)
>>>
>>> discreteVal = New ParameterDiscreteValue
>>> discreteVal.Value = "2344"
>>> paramField.CurrentValues.Add(discreteVal)
>>>
>>> paramFields.Add(paramField)
>>>
>>> paramField = New ParameterField
>>>
>>> paramField.ParameterFieldName = "Periode"
>>>
>>> rangeVal.StartValue = BeginPeriode
>>> rangeVal.EndValue = EindPeriode
>>> paramField.CurrentValues.Add(rangeVal)
>>>
>>> paramFields.Add(paramField)
>>>
>>> crViewer.ParameterFieldInfo = paramFields
>>> myReport.SetParameterValue("Periode", rangeVal)
>>> myReport.SetParameterValue("FiliaalKeuze", discreteVal)
>>> crViewer.ReportSource = myReport
>>>
>>> As you can see I use myReport.SetParameterValue 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
>>>
>>>
>>>
>>>
>>
>>
>
>
Author
20 Feb 2006 4:31 PM
Alison Givens
> Perhaps you could share your resulting code for comparison?  Did you see
> that I suggested the error in your code was
>
> myReport.SetParameterValue("FiliaalKeuze", 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 CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.CrystalReports.Engine.ReportDocument
Imports CrystalDecisions.Shared
Imports System.IO


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



        Dim myReport As RapportAIRCOStoringen
        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.QueryString("BeginPeriode")
            EindPeriode = Request.QueryString("EindPeriode")
        Catch ex As Exception
            Dim exCustom As ApplicationException
            exCustom = New ApplicationException("Unable to parse Query
Paramaters.", ex)
            Throw exCustom
        End Try

        'Todo wrap in try
        paramField = CreateParameter("FiliaalKeuze")
        paramField.CurrentValues.Add(CreateParameterDiscreteValue(2044))
        paramField.CurrentValues.Add(CreateParameterDiscreteValue(2344))
        myReport.SetParameterValue("FiliaalKeuze", paramField)


        'Todo wrap in try
        paramField = CreateParameter("Periode")
        paramField.CurrentValues.Add(CreateParameterRangeValue(BeginPeriode,
EindPeriode))
        myReport.SetParameterValue("Periode", paramField)


        crViewer.ReportSource = myReport


        'exporteren to pdf
        Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
        Dim myDiskFileDestinationOptions As
CrystalDecisions.Shared.DiskFileDestinationOptions
        Dim myExportFile As String



        myExportFile = "\\192.168.2.106\syn2sql$\PDF_" &
Session.SessionID.ToString & ".pdf"
        myDiskFileDestinationOptions = New
CrystalDecisions.Shared.DiskFileDestinationOptions
        myDiskFileDestinationOptions.DiskFileName = myExportFile
        myExportOptions = myReport.ExportOptions
        With myExportOptions
            .DestinationOptions = myDiskFileDestinationOptions
            .ExportDestinationType = .ExportDestinationType.DiskFile
            .ExportFormatType = .ExportFormatType.PortableDocFormat
        End With

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

        Session("exportbestand") = myExportFile
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) 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.EventArgs) Handles cmdPrint.Click
        Response.ClearContent()
        Response.ClearHeaders()
        Response.ContentType = "application/pdf"
        Dim myExportFile As String = CType(Session.Item("exportbestand"),
String)

        Response.WriteFile(myExportFile)
        Response.Flush()
        Response.Close()

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

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

        paramField = New ParameterField
        paramField.ParameterFieldName = ParameterName

        'Return paramField

    End Function

    Private Function CreateParameterDiscreteValue(ByVal Value As Object) As
ParameterDiscreteValue()

        Dim paramDiscreteValue As ParameterDiscreteValue
        paramDiscreteValue = New ParameterDiscreteValue
        paramDiscreteValue = Value

        'Return paramDiscreteValue

    End Function

    Private Function CreateParameterRangeValue(ByVal StartRange As Object,
ByVal EndRange As Object) As ParameterRangeValue
        Dim paramRangeValue As ParameterRangeValue

        paramRangeValue = New ParameterRangeValue

        paramRangeValue.StartValue = StartRange
        paramRangeValue.EndValue = EndRange

        Return paramRangeValue
    End Function


    Private Sub cmdEerste_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdEerste.Click
        crViewer.ShowFirstPage()
    End Sub

    Private Sub cmdLaatste_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdLaatste.Click
        crViewer.ShowLastPage()
    End Sub

    Private Sub cmdTerug_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdTerug.Click
        crViewer.ShowPreviousPage()
    End Sub

    Private Sub cmdVerder_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdVerder.Click
        crViewer.ShowNextPage()
    End Sub

    Private Sub drpZoom_SelectedIndexChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles drpZoom.SelectedIndexChanged
        crViewer.Zoom(drpZoom.SelectedItem.Value)
    End Sub
    Private Sub Page_Unload(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Unload
        Dim myExportFile As String = CType(Session.Item("exportbestand"),
String)

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






Show quoteHide quote
>
> "Alison Givens" <i***@cross-it.nl> wrote in message
> news:eeEqNEgNGHA.1288@TK2MSFTNGP09.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
>> CrystalDecisions.Shared.ParameterField' cannot be converted
>> to 'Crystal.Decisions.Shared.ParameterField'
>>
>> Return paramField
>> The text is:
>> Value of type 'CrystalDecisions.Shared.ParameterField' cannot be
>> converted
>> to '1 dimensional array of Crystal.Decisions.Shared.ParameterField'
>>
>> Same for
>> paramField = CreateParamater("Periode")
>> Return paramDiscreteValue
>>
>> Any idea what causes this?
>>
>> Alison
>>
>>
>> "AMDRIT" <amd***@hotmail.com> wrote in message
>> news:urCzE10MGHA.720@TK2MSFTNGP14.phx.gbl...
>>> Wow, you do all that for Crystal Reports?  What is
>>> RapportAIRCOStoringen?
>>>
>>>
>>> Here is all I do for CR
>>>
>>> Dim x As CrystalDecisions.CrystalReports.Engine.ReportDocument
>>>
>>> x.Load(sReportPath) 'Reports are not embedded resources
>>> x.SetParameterValue("Paramater1", Paramaters(1))      'Dynamic
>>> Paramaters
>>> x.SetParameterValue("Paramater2", Paramaters(2))
>>> x.SetDataSource(mydata) 'Strongly Typed Datasets
>>>
>>> Me.CrystalReportViewer1.ReportSource = x
>>> Me.CrystalReportViewer1.PrintReport()
>>>
>>>
>>> '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.SetParameterValue("FiliaalKeuze", discreteVal)
>>>
>>> Why are you setting the crView paramaters and the myReport paramaters?
>>>  -->crViewer.ParameterFieldInfo = paramFields
>>>  -->myReport.SetParameterValue("Periode", 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 RapportAIRCOStoringen
>>>    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.QueryString("BeginPeriode")
>>>      EindPeriode = Request.QueryString("EindPeriode")
>>>    Catch ex As Exception
>>>      Dim exCustom As ApplicationException
>>>      exCustom = New ApplicationException("Unable to parse Query
>>> Paramaters.", ex)
>>>      Throw exCustom
>>>    End Try
>>>
>>>    'Todo wrap in try
>>>    paramField = CreateParamater("FiliaalKeuze")
>>>    paramField.CurrentValues.Add(CreateParameterDiscreteValue(2044))
>>>    paramField.CurrentValues.Add(CreateParameterDiscreteValue(2344))
>>>    myReport.SetParameterValue("FiliaalKeuze", paramField)
>>>    'paramFields.Add(paramField) --> Not needed
>>>
>>>    'Todo wrap in try
>>>    paramField = CreateParamater("Periode")
>>>    paramField.CurrentValues.Add(CreateParameterRangeValue(BeginPeriode,
>>> EindPeriode))
>>>    myReport.SetParameterValue("Periode", paramField)
>>>    'paramFields.Add(paramField)--> Not needed
>>>
>>>    'Todo wrap in try, i don't think you need this
>>>    'myReport.SetParameterValue("Periode", rangeVal)
>>>    'myReport.SetParameterValue("FiliaalKeuze", discreteVal)
>>>
>>>    'Todo, determine if we need this step; I don't think you do
>>>    'crViewer.ParameterFieldInfo = paramFields
>>>
>>>    crViewer.ReportSource = myReport
>>>
>>>  End Sub
>>>
>>>  Private Function CreateParamater(ByVal ParamaterName As String) As
>>> ParameterField
>>>    Dim paramField As ParameterField
>>>
>>>    paramField = New ParameterField
>>>    paramField.ParameterFieldName = ParamaterName
>>>
>>>    Return paramField
>>>
>>>  End Function
>>>
>>>  Private Function CreateParameterDiscreteValue(ByVal Value As Object) As
>>> ParameterDiscreteValue
>>>
>>>    Dim paramDiscreteValue As ParameterDiscreteValue
>>>    paramDiscreteValue = New ParameterDiscreteValue
>>>    paramDiscreteValue = Value
>>>
>>>    Return paramDiscreteValue
>>>
>>>  End Function
>>>
>>>  Private Function CreateParameterRangeValue(ByVal StartRange As Object,
>>> ByVal EndRange As Object) As ParameterRangeValue
>>>    Dim paramRangeValue As ParameterRangeValue
>>>
>>>    paramRangeValue = New ParameterRangeValue
>>>
>>>    paramRangeValue.StartValue = StartRange
>>>    paramRangeValue.EndValue = EndRange
>>>
>>>    Return paramRangeValue
>>>  End Function
>>>
>>> "Alison Givens" <i***@cross-it.nl> wrote in message
>>> news:eW4b66tMGHA.668@TK2MSFTNGP11.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.QueryString("BeginPeriode")
>>>> EindPeriode = Request.QueryString("EindPeriode")
>>>>
>>>> Dim myReport As New RapportAIRCOStoringen
>>>>
>>>> Dim paramFields As New ParameterFields
>>>> Dim paramField As New ParameterField
>>>> Dim discreteVal As New ParameterDiscreteValue
>>>> Dim rangeVal As New ParameterRangeValue
>>>>
>>>> paramField.ParameterFieldName = "FiliaalKeuze"
>>>> discreteVal.Value = "2044"
>>>> paramField.CurrentValues.Add(discreteVal)
>>>>
>>>> discreteVal = New ParameterDiscreteValue
>>>> discreteVal.Value = "2344"
>>>> paramField.CurrentValues.Add(discreteVal)
>>>>
>>>> paramFields.Add(paramField)
>>>>
>>>> paramField = New ParameterField
>>>>
>>>> paramField.ParameterFieldName = "Periode"
>>>>
>>>> rangeVal.StartValue = BeginPeriode
>>>> rangeVal.EndValue = EindPeriode
>>>> paramField.CurrentValues.Add(rangeVal)
>>>>
>>>> paramFields.Add(paramField)
>>>>
>>>> crViewer.ParameterFieldInfo = paramFields
>>>> myReport.SetParameterValue("Periode", rangeVal)
>>>> myReport.SetParameterValue("FiliaalKeuze", discreteVal)
>>>> crViewer.ReportSource = myReport
>>>>
>>>> As you can see I use myReport.SetParameterValue 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
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
Author
20 Feb 2006 6:00 PM
AMDRIT
Ok, first the isue you were having with the "Blue lines" is:

Private Function CreateParameterDiscreteValue(ByVal Value As Object) As
ParameterDiscreteValue()
-->        Retun type is expecting an array of ParameterDiscreteValue

it should be

Private Function CreateParameterDiscreteValue(ByVal Value As Object) As
ParameterDiscreteValue
-->        Retun type is expecting an single ParameterDiscreteValue

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.EventArgs) Handles MyBase.Init
    'CODEGEN: This method call is required by the Web Form Designer
    'Do not modify it using the code editor.
    InitializeComponent()

    Dim myReport As RapportAIRCOStoringen
    Dim myExportOptions As CrystalDecisions.Shared.ExportOptions

    Try

      Try
        PrepareReport(myReport)
      Catch ex As Exception
        Dim exc As ApplicationException
        exc = New ApplicationException("Unable to prepare report.", ex)
        Throw exc
      End Try

      Try
        'exporteren to pdf
        myExportOptions = GetExportOptions(FileNameFormats.GUIDNoDashes,
CType(myReport,
CrystalDecisions.CrystalReports.Engine.ReportDocument).ExportOptions)
        myReport.Export()

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

      crViewer.ReportSource = myReport

      Session("exportbestand") = CType(myExportOptions.DestinationOptions,
CrystalDecisions.Shared.DiskFileDestinationOptions).DiskFileName

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

  End Sub

#Region "Page Implementation"

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

  Private Sub Page_Unload(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Unload
    Dim myExportFile As String = CType(Session.Item("exportbestand"),
String)

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

#End Region

#Region "Report Setup"

  Private Sub PrepareReport(ByVal myReport As
CrystalDecisions.CrystalReports.Engine.ReportDocument)

    Dim paramFields As ParameterFields
    Dim paramField As ParameterField

    Const SessionExecption As String = "Unable to read session objects."

    Try

      paramFields = New ParameterFields
      Try
        paramField = CreateParameter("FiliaalKeuze")
        paramField.CurrentValues.Add(CreateParameterDiscreteValue(GetSessionValue("DiscreteValue1")))
        paramField.CurrentValues.Add(CreateParameterDiscreteValue(GetSessionValue("DiscreteValue1")))
      Catch ex As Exception
        Dim exc As System.ApplicationException
        exc = New System.ApplicationException(SessionExecption, ex)
        Throw exc
      End Try

      myReport.SetParameterValue("FiliaalKeuze", paramField)

      Try
        'Todo wrap in try
        paramField = CreateParameter("Periode")
        paramField.CurrentValues.Add(CreateParameterRangeValue(GetSessionValue("BeginPeriode"),
GetSessionValue("EindPeriode")))
      Catch ex As Exception
        Dim exc As System.ApplicationException
        exc = New System.ApplicationException(SessionExecption, ex)
        Throw exc
      End Try

      myReport.SetParameterValue("Periode", paramField)

    Catch ex As Exception

      Dim exc As System.ApplicationException
      exc = New System.ApplicationException("Unable 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.ParameterFieldName = ParameterName

    Return paramField

  End Function

  Private Function CreateParameterDiscreteValue(ByVal Value As Object) As
ParameterDiscreteValue()

    Dim paramDiscreteValue As ParameterDiscreteValue
    paramDiscreteValue = New ParameterDiscreteValue
    paramDiscreteValue = Value

    'Return paramDiscreteValue

  End Function

  Private Function CreateParameterRangeValue(ByVal StartRange As Object,
ByVal EndRange As Object) As ParameterRangeValue
    Dim paramRangeValue As ParameterRangeValue

    paramRangeValue = New ParameterRangeValue

    paramRangeValue.StartValue = StartRange
    paramRangeValue.EndValue = EndRange

    Return paramRangeValue
  End Function

#End Region

#Region "Report Export"

  Private Function GetExportOptions(ByVal UniqueFormat As FileNameFormats,
ByVal ExportOptions As CrystalDecisions.Shared.ExportOptions) As
CrystalDecisions.Shared.ExportOptions

    Dim myExportFile As String
    Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
    Dim myDiskFileDestinationOptions As
CrystalDecisions.Shared.DiskFileDestinationOptions

    Try

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

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

      myDiskFileDestinationOptions = New
CrystalDecisions.Shared.DiskFileDestinationOptions
      myDiskFileDestinationOptions.DiskFileName = myExportFile

      myExportOptions = ExportOptions

      With myExportOptions
        .DestinationOptions = myDiskFileDestinationOptions
        .ExportDestinationType = .ExportDestinationType.DiskFile
        .ExportFormatType = .ExportFormatType.PortableDocFormat
      End With

    Catch ex As Exception

      Dim exc As System.ApplicationException
      exc = New System.ApplicationException("Unable to prepare export
options.", ex)
      Throw exc

    End Try

    Return myExportOptions

  End Function

  Private Function GetExportRoot(ByVal FromApplication As Boolean) As String

    Dim strExportRoot As String

    If FromApplication Then
      Try
        Application.lock()
        strExportRoot = Application("ReportExportRoot")
      Catch ex As Exception
        Dim exc As ApplicationException
        exc = New ApplicationException("Unable to lock Web Application for
read.", ex)
        Throw exc
      Finally
        Application.unlock()
      End Try
    Else
      strExportRoot = Session("ReportExportRoot")
    End If

    Return strExportRoot

  End Function

#End Region

#Region "Navigation Implementation"

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

    Response.ClearContent()
    Response.ClearHeaders()
    Response.ContentType = "application/pdf"

    Dim myExportFile As String = CType(Session.Item("exportbestand"),
String)

    Response.WriteFile(myExportFile)
    Response.Flush()
    Response.Close()

    System.IO.File.Delete(myExportFile)

  End Sub

  Private Sub cmdEerste_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdEerste.Click
    crViewer.ShowFirstPage()
  End Sub

  Private Sub cmdLaatste_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdLaatste.Click
    crViewer.ShowLastPage()
  End Sub

  Private Sub cmdTerug_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdTerug.Click
    crViewer.ShowPreviousPage()
  End Sub

  Private Sub cmdVerder_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdVerder.Click
    crViewer.ShowNextPage()
  End Sub

  Private Sub drpZoom_SelectedIndexChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles drpZoom.SelectedIndexChanged
    crViewer.Zoom(drpZoom.SelectedItem.Value)
  End Sub

#End Region


Show quoteHide quote
"Alison Givens" <i***@cross-it.nl> wrote in message
news:%23RW%23bsjNGHA.2124@TK2MSFTNGP14.phx.gbl...
>> Perhaps you could share your resulting code for comparison?  Did you see
>> that I suggested the error in your code was
>>
>> myReport.SetParameterValue("FiliaalKeuze", 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 CrystalDecisions.CrystalReports.Engine
> Imports CrystalDecisions.CrystalReports.Engine.ReportDocument
> Imports CrystalDecisions.Shared
> Imports System.IO
>
>
> Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Init
>        'CODEGEN: This method call is required by the Web Form Designer
>        'Do not modify it using the code editor.
>        InitializeComponent()
>
>
>
>        Dim myReport As RapportAIRCOStoringen
>        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.QueryString("BeginPeriode")
>            EindPeriode = Request.QueryString("EindPeriode")
>        Catch ex As Exception
>            Dim exCustom As ApplicationException
>            exCustom = New ApplicationException("Unable to parse Query
> Paramaters.", ex)
>            Throw exCustom
>        End Try
>
>        'Todo wrap in try
>        paramField = CreateParameter("FiliaalKeuze")
>        paramField.CurrentValues.Add(CreateParameterDiscreteValue(2044))
>        paramField.CurrentValues.Add(CreateParameterDiscreteValue(2344))
>        myReport.SetParameterValue("FiliaalKeuze", paramField)
>
>
>        'Todo wrap in try
>        paramField = CreateParameter("Periode")
>
> paramField.CurrentValues.Add(CreateParameterRangeValue(BeginPeriode,
> EindPeriode))
>        myReport.SetParameterValue("Periode", paramField)
>
>
>        crViewer.ReportSource = myReport
>
>
>        'exporteren to pdf
>        Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
>        Dim myDiskFileDestinationOptions As
> CrystalDecisions.Shared.DiskFileDestinationOptions
>        Dim myExportFile As String
>
>
>
>        myExportFile = "\\192.168.2.106\syn2sql$\PDF_" &
> Session.SessionID.ToString & ".pdf"
>        myDiskFileDestinationOptions = New
> CrystalDecisions.Shared.DiskFileDestinationOptions
>        myDiskFileDestinationOptions.DiskFileName = myExportFile
>        myExportOptions = myReport.ExportOptions
>        With myExportOptions
>            .DestinationOptions = myDiskFileDestinationOptions
>            .ExportDestinationType = .ExportDestinationType.DiskFile
>            .ExportFormatType = .ExportFormatType.PortableDocFormat
>        End With
>
>        Try
>            myReport.Export()
>        Catch err As Exception
>            Response.Write("<BR>")
>            Response.Write(err.Message.ToString)
>        End Try
>
>        Session("exportbestand") = myExportFile
>    End Sub
>
> #End Region
>
>    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) 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.EventArgs) Handles cmdPrint.Click
>        Response.ClearContent()
>        Response.ClearHeaders()
>        Response.ContentType = "application/pdf"
>        Dim myExportFile As String = CType(Session.Item("exportbestand"),
> String)
>
>        Response.WriteFile(myExportFile)
>        Response.Flush()
>        Response.Close()
>
>        System.IO.File.Delete(myExportFile)
>    End Sub
>
>    Private Function CreateParameter(ByVal ParameterName As String) As
> ParameterField()
>        Dim paramField As ParameterField
>
>        paramField = New ParameterField
>        paramField.ParameterFieldName = ParameterName
>
>        'Return paramField
>
>    End Function
>
>    Private Function CreateParameterDiscreteValue(ByVal Value As Object) As
> ParameterDiscreteValue()
>
>        Dim paramDiscreteValue As ParameterDiscreteValue
>        paramDiscreteValue = New ParameterDiscreteValue
>        paramDiscreteValue = Value
>
>        'Return paramDiscreteValue
>
>    End Function
>
>    Private Function CreateParameterRangeValue(ByVal StartRange As Object,
> ByVal EndRange As Object) As ParameterRangeValue
>        Dim paramRangeValue As ParameterRangeValue
>
>        paramRangeValue = New ParameterRangeValue
>
>        paramRangeValue.StartValue = StartRange
>        paramRangeValue.EndValue = EndRange
>
>        Return paramRangeValue
>    End Function
>
>
>    Private Sub cmdEerste_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles cmdEerste.Click
>        crViewer.ShowFirstPage()
>    End Sub
>
>    Private Sub cmdLaatste_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles cmdLaatste.Click
>        crViewer.ShowLastPage()
>    End Sub
>
>    Private Sub cmdTerug_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles cmdTerug.Click
>        crViewer.ShowPreviousPage()
>    End Sub
>
>    Private Sub cmdVerder_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles cmdVerder.Click
>        crViewer.ShowNextPage()
>    End Sub
>
>    Private Sub drpZoom_SelectedIndexChanged(ByVal sender As Object, ByVal
> e As System.EventArgs) Handles drpZoom.SelectedIndexChanged
>        crViewer.Zoom(drpZoom.SelectedItem.Value)
>    End Sub
>    Private Sub Page_Unload(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles MyBase.Unload
>        Dim myExportFile As String = CType(Session.Item("exportbestand"),
> String)
>
>        System.IO.File.Delete(myExportFile)
>    End Sub
> End Class
>
>
>
>
>
>
>>
>> "Alison Givens" <i***@cross-it.nl> wrote in message
>> news:eeEqNEgNGHA.1288@TK2MSFTNGP09.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
>>> CrystalDecisions.Shared.ParameterField' cannot be converted
>>> to 'Crystal.Decisions.Shared.ParameterField'
>>>
>>> Return paramField
>>> The text is:
>>> Value of type 'CrystalDecisions.Shared.ParameterField' cannot be
>>> converted
>>> to '1 dimensional array of Crystal.Decisions.Shared.ParameterField'
>>>
>>> Same for
>>> paramField = CreateParamater("Periode")
>>> Return paramDiscreteValue
>>>
>>> Any idea what causes this?
>>>
>>> Alison
>>>
>>>
>>> "AMDRIT" <amd***@hotmail.com> wrote in message
>>> news:urCzE10MGHA.720@TK2MSFTNGP14.phx.gbl...
>>>> Wow, you do all that for Crystal Reports?  What is
>>>> RapportAIRCOStoringen?
>>>>
>>>>
>>>> Here is all I do for CR
>>>>
>>>> Dim x As CrystalDecisions.CrystalReports.Engine.ReportDocument
>>>>
>>>> x.Load(sReportPath) 'Reports are not embedded resources
>>>> x.SetParameterValue("Paramater1", Paramaters(1))      'Dynamic
>>>> Paramaters
>>>> x.SetParameterValue("Paramater2", Paramaters(2))
>>>> x.SetDataSource(mydata) 'Strongly Typed Datasets
>>>>
>>>> Me.CrystalReportViewer1.ReportSource = x
>>>> Me.CrystalReportViewer1.PrintReport()
>>>>
>>>>
>>>> '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.SetParameterValue("FiliaalKeuze", discreteVal)
>>>>
>>>> Why are you setting the crView paramaters and the myReport paramaters?
>>>>  -->crViewer.ParameterFieldInfo = paramFields
>>>>  -->myReport.SetParameterValue("Periode", 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 RapportAIRCOStoringen
>>>>    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.QueryString("BeginPeriode")
>>>>      EindPeriode = Request.QueryString("EindPeriode")
>>>>    Catch ex As Exception
>>>>      Dim exCustom As ApplicationException
>>>>      exCustom = New ApplicationException("Unable to parse Query
>>>> Paramaters.", ex)
>>>>      Throw exCustom
>>>>    End Try
>>>>
>>>>    'Todo wrap in try
>>>>    paramField = CreateParamater("FiliaalKeuze")
>>>>    paramField.CurrentValues.Add(CreateParameterDiscreteValue(2044))
>>>>    paramField.CurrentValues.Add(CreateParameterDiscreteValue(2344))
>>>>    myReport.SetParameterValue("FiliaalKeuze", paramField)
>>>>    'paramFields.Add(paramField) --> Not needed
>>>>
>>>>    'Todo wrap in try
>>>>    paramField = CreateParamater("Periode")
>>>>    paramField.CurrentValues.Add(CreateParameterRangeValue(BeginPeriode,
>>>> EindPeriode))
>>>>    myReport.SetParameterValue("Periode", paramField)
>>>>    'paramFields.Add(paramField)--> Not needed
>>>>
>>>>    'Todo wrap in try, i don't think you need this
>>>>    'myReport.SetParameterValue("Periode", rangeVal)
>>>>    'myReport.SetParameterValue("FiliaalKeuze", discreteVal)
>>>>
>>>>    'Todo, determine if we need this step; I don't think you do
>>>>    'crViewer.ParameterFieldInfo = paramFields
>>>>
>>>>    crViewer.ReportSource = myReport
>>>>
>>>>  End Sub
>>>>
>>>>  Private Function CreateParamater(ByVal ParamaterName As String) As
>>>> ParameterField
>>>>    Dim paramField As ParameterField
>>>>
>>>>    paramField = New ParameterField
>>>>    paramField.ParameterFieldName = ParamaterName
>>>>
>>>>    Return paramField
>>>>
>>>>  End Function
>>>>
>>>>  Private Function CreateParameterDiscreteValue(ByVal Value As Object)
>>>> As ParameterDiscreteValue
>>>>
>>>>    Dim paramDiscreteValue As ParameterDiscreteValue
>>>>    paramDiscreteValue = New ParameterDiscreteValue
>>>>    paramDiscreteValue = Value
>>>>
>>>>    Return paramDiscreteValue
>>>>
>>>>  End Function
>>>>
>>>>  Private Function CreateParameterRangeValue(ByVal StartRange As Object,
>>>> ByVal EndRange As Object) As ParameterRangeValue
>>>>    Dim paramRangeValue As ParameterRangeValue
>>>>
>>>>    paramRangeValue = New ParameterRangeValue
>>>>
>>>>    paramRangeValue.StartValue = StartRange
>>>>    paramRangeValue.EndValue = EndRange
>>>>
>>>>    Return paramRangeValue
>>>>  End Function
>>>>
>>>> "Alison Givens" <i***@cross-it.nl> wrote in message
>>>> news:eW4b66tMGHA.668@TK2MSFTNGP11.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.QueryString("BeginPeriode")
>>>>> EindPeriode = Request.QueryString("EindPeriode")
>>>>>
>>>>> Dim myReport As New RapportAIRCOStoringen
>>>>>
>>>>> Dim paramFields As New ParameterFields
>>>>> Dim paramField As New ParameterField
>>>>> Dim discreteVal As New ParameterDiscreteValue
>>>>> Dim rangeVal As New ParameterRangeValue
>>>>>
>>>>> paramField.ParameterFieldName = "FiliaalKeuze"
>>>>> discreteVal.Value = "2044"
>>>>> paramField.CurrentValues.Add(discreteVal)
>>>>>
>>>>> discreteVal = New ParameterDiscreteValue
>>>>> discreteVal.Value = "2344"
>>>>> paramField.CurrentValues.Add(discreteVal)
>>>>>
>>>>> paramFields.Add(paramField)
>>>>>
>>>>> paramField = New ParameterField
>>>>>
>>>>> paramField.ParameterFieldName = "Periode"
>>>>>
>>>>> rangeVal.StartValue = BeginPeriode
>>>>> rangeVal.EndValue = EindPeriode
>>>>> paramField.CurrentValues.Add(rangeVal)
>>>>>
>>>>> paramFields.Add(paramField)
>>>>>
>>>>> crViewer.ParameterFieldInfo = paramFields
>>>>> myReport.SetParameterValue("Periode", rangeVal)
>>>>> myReport.SetParameterValue("FiliaalKeuze", discreteVal)
>>>>> crViewer.ReportSource = myReport
>>>>>
>>>>> As you can see I use myReport.SetParameterValue 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
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
Author
21 Feb 2006 8:40 AM
Alison Givens
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(GetExportRoot,
String.Format("PDF_{0}.pdf", myExportFile))
Says:Argument not specified for parameter 'FromApplication' of
'Private Function GetExportRoot(FromApplication 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.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
        Dim myReport As RapportAIRCOStoringen
        Dim myExportOptions As CrystalDecisions.Shared.ExportOptions

        Try

            Try
                PrepareReport(myReport)
            Catch ex As Exception
                Dim exc As ApplicationException
                exc = New ApplicationException("Unable to prepare report.",
ex)
                Throw exc
            End Try

            Try
                'exporteren to pdf
                myExportOptions =
GetExportOptions(FileNameFormats.GUIDNoDashes, CType(myReport,
CrystalDecisions.CrystalReports.Engine.ReportDocument).ExportOptions)
                myReport.Export()

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

            crViewer.ReportSource = myReport

            Session("exportbestand") =
CType(myExportOptions.DestinationOptions,
CrystalDecisions.Shared.DiskFileDestinationOptions).DiskFileName

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




    End Sub

#End Region

#Region "Page Implementation"

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

    Private Sub Page_Unload(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Unload
        Dim myExportFile As String = CType(Session.Item("exportbestand"),
String)

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

#End Region

#Region "Report Setup"

    Private Sub PrepareReport(ByVal myReport As
CrystalDecisions.CrystalReports.Engine.ReportDocument)

        Dim paramFields As ParameterFields
        Dim paramField As ParameterField

        Const SessionExecption As String = "Unable to read session objects."

        Try

            paramFields = New ParameterFields
            Try
                paramField = CreateParameter("FiliaalKeuze")
                paramField.CurrentValues.Add(CreateParameterDiscreteValue(GetSessionValue("DiscreteValue1")))
                paramField.CurrentValues.Add(CreateParameterDiscreteValue(GetSessionValue("DiscreteValue1")))

            Catch ex As Exception
                Dim exc As System.ApplicationException
                exc = New System.ApplicationException(SessionExecption, ex)
                Throw exc
            End Try

            myReport.SetParameterValue("FiliaalKeuze", paramField)

            Try
                'Todo wrap in try
                paramField = CreateParameter("Periode")
                paramField.CurrentValues.Add(CreateParameterRangeValue(GetSessionValue("BeginPeriode"),
GetSessionValue("EindPeriode")))
            Catch ex As Exception
                Dim exc As System.ApplicationException
                exc = New System.ApplicationException(SessionExecption, ex)
                Throw exc
            End Try

            myReport.SetParameterValue("Periode", paramField)

        Catch ex As Exception

            Dim exc As System.ApplicationException
            exc = New System.ApplicationException("Unable 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.ParameterFieldName = ParameterName

        Return paramField

    End Function

    Private Function CreateParameterDiscreteValue(ByVal Value As Object) As
ParameterDiscreteValue

        Dim paramDiscreteValue As ParameterDiscreteValue
        paramDiscreteValue = New ParameterDiscreteValue
        paramDiscreteValue = Value

        Return paramDiscreteValue

    End Function

    Private Function CreateParameterRangeValue(ByVal StartRange As Object,
ByVal EndRange As Object) As ParameterRangeValue
        Dim paramRangeValue As ParameterRangeValue

        paramRangeValue = New ParameterRangeValue

        paramRangeValue.StartValue = StartRange
        paramRangeValue.EndValue = EndRange

        Return paramRangeValue
    End Function

#End Region

#Region "Report Export"

    Private Function GetExportOptions(ByVal UniqueFormat As FileNameFormats,
ByVal ExportOptions As CrystalDecisions.Shared.ExportOptions) As
CrystalDecisions.Shared.ExportOptions

        Dim myExportFile As String
        Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
        Dim myDiskFileDestinationOptions As
CrystalDecisions.Shared.DiskFileDestinationOptions

        Try

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

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

            myDiskFileDestinationOptions = New
CrystalDecisions.Shared.DiskFileDestinationOptions
            myDiskFileDestinationOptions.DiskFileName = myExportFile

            myExportOptions = ExportOptions

            With myExportOptions
                .DestinationOptions = myDiskFileDestinationOptions
                .ExportDestinationType = .ExportDestinationType.DiskFile
                .ExportFormatType = .ExportFormatType.PortableDocFormat
            End With

        Catch ex As Exception

            Dim exc As System.ApplicationException
            exc = New System.ApplicationException("Unable to prepare export
options.", ex)
            Throw exc

        End Try

        Return myExportOptions

    End Function

    Private Function GetExportRoot(ByVal FromApplication As Boolean) As
String

        Dim strExportRoot As String

        If FromApplication Then
            Try
                Application.Lock()
                strExportRoot = Application("ReportExportRoot")
            Catch ex As Exception
                Dim exc As ApplicationException
                exc = New ApplicationException("Unable to lock Web
Application for read.", ex)
                Throw exc
            Finally
                Application.UnLock()
            End Try
        Else
            strExportRoot = Session("ReportExportRoot")
        End If

        Return strExportRoot

    End Function

#End Region

#Region "Navigation Implementation"

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

        Response.ClearContent()
        Response.ClearHeaders()
        Response.ContentType = "application/pdf"

        Dim myExportFile As String = CType(Session.Item("exportbestand"),
String)

        Response.WriteFile(myExportFile)
        Response.Flush()
        Response.Close()

        System.IO.File.Delete(myExportFile)

    End Sub

    Private Sub cmdEerste_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdEerste.Click
        crViewer.ShowFirstPage()
    End Sub

    Private Sub cmdLaatste_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdLaatste.Click
        crViewer.ShowLastPage()
    End Sub

    Private Sub cmdTerug_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdTerug.Click
        crViewer.ShowPreviousPage()
    End Sub

    Private Sub cmdVerder_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdVerder.Click
        crViewer.ShowNextPage()
    End Sub

  Private Sub drpZoom_SelectedIndexChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles drpZoom.SelectedIndexChanged
        crViewer.Zoom(drpZoom.SelectedItem.Value)
    End Sub

#End Region


End Class




Show quoteHide quote
"AMDRIT" <amd***@hotmail.com> wrote in message
news:OpMDndkNGHA.2064@TK2MSFTNGP09.phx.gbl...
> Ok, first the isue you were having with the "Blue lines" is:
>
> Private Function CreateParameterDiscreteValue(ByVal Value As Object) As
> ParameterDiscreteValue()
> -->        Retun type is expecting an array of ParameterDiscreteValue
>
> it should be
>
> Private Function CreateParameterDiscreteValue(ByVal Value As Object) As
> ParameterDiscreteValue
> -->        Retun type is expecting an single ParameterDiscreteValue
>
> 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.EventArgs) Handles MyBase.Init
>    'CODEGEN: This method call is required by the Web Form Designer
>    'Do not modify it using the code editor.
>    InitializeComponent()
>
>    Dim myReport As RapportAIRCOStoringen
>    Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
>
>    Try
>
>      Try
>        PrepareReport(myReport)
>      Catch ex As Exception
>        Dim exc As ApplicationException
>        exc = New ApplicationException("Unable to prepare report.", ex)
>        Throw exc
>      End Try
>
>      Try
>        'exporteren to pdf
>        myExportOptions = GetExportOptions(FileNameFormats.GUIDNoDashes,
> CType(myReport,
> CrystalDecisions.CrystalReports.Engine.ReportDocument).ExportOptions)
>        myReport.Export()
>
>      Catch ex As Exception
>        Dim exc As ApplicationException
>        exc = New ApplicationException("Unable to export report.", ex)
>        Throw exc
>      End Try
>
>      crViewer.ReportSource = myReport
>
>      Session("exportbestand") = CType(myExportOptions.DestinationOptions,
> CrystalDecisions.Shared.DiskFileDestinationOptions).DiskFileName
>
>    Catch err As Exception
>      Response.Write("<BR>")
>      Response.Write(err.Message.ToString)
>    End Try
>
>  End Sub
>
> #Region "Page Implementation"
>
>  Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
>    'Put user code to initialize the page here
>  End Sub
>
>  Private Sub Page_Unload(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles MyBase.Unload
>    Dim myExportFile As String = CType(Session.Item("exportbestand"),
> String)
>
>    System.IO.File.Delete(myExportFile)
>  End Sub
>
> #End Region
>
> #Region "Report Setup"
>
>  Private Sub PrepareReport(ByVal myReport As
> CrystalDecisions.CrystalReports.Engine.ReportDocument)
>
>    Dim paramFields As ParameterFields
>    Dim paramField As ParameterField
>
>    Const SessionExecption As String = "Unable to read session objects."
>
>    Try
>
>      paramFields = New ParameterFields
>      Try
>        paramField = CreateParameter("FiliaalKeuze")
>
> paramField.CurrentValues.Add(CreateParameterDiscreteValue(GetSessionValue("DiscreteValue1")))
>
> paramField.CurrentValues.Add(CreateParameterDiscreteValue(GetSessionValue("DiscreteValue1")))
>      Catch ex As Exception
>        Dim exc As System.ApplicationException
>        exc = New System.ApplicationException(SessionExecption, ex)
>        Throw exc
>      End Try
>
>      myReport.SetParameterValue("FiliaalKeuze", paramField)
>
>      Try
>        'Todo wrap in try
>        paramField = CreateParameter("Periode")
>
> paramField.CurrentValues.Add(CreateParameterRangeValue(GetSessionValue("BeginPeriode"),
> GetSessionValue("EindPeriode")))
>      Catch ex As Exception
>        Dim exc As System.ApplicationException
>        exc = New System.ApplicationException(SessionExecption, ex)
>        Throw exc
>      End Try
>
>      myReport.SetParameterValue("Periode", paramField)
>
>    Catch ex As Exception
>
>      Dim exc As System.ApplicationException
>      exc = New System.ApplicationException("Unable 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.ParameterFieldName = ParameterName
>
>    Return paramField
>
>  End Function
>
>  Private Function CreateParameterDiscreteValue(ByVal Value As Object) As
> ParameterDiscreteValue()
>
>    Dim paramDiscreteValue As ParameterDiscreteValue
>    paramDiscreteValue = New ParameterDiscreteValue
>    paramDiscreteValue = Value
>
>    'Return paramDiscreteValue
>
>  End Function
>
>  Private Function CreateParameterRangeValue(ByVal StartRange As Object,
> ByVal EndRange As Object) As ParameterRangeValue
>    Dim paramRangeValue As ParameterRangeValue
>
>    paramRangeValue = New ParameterRangeValue
>
>    paramRangeValue.StartValue = StartRange
>    paramRangeValue.EndValue = EndRange
>
>    Return paramRangeValue
>  End Function
>
> #End Region
>
> #Region "Report Export"
>
>  Private Function GetExportOptions(ByVal UniqueFormat As FileNameFormats,
> ByVal ExportOptions As CrystalDecisions.Shared.ExportOptions) As
> CrystalDecisions.Shared.ExportOptions
>
>    Dim myExportFile As String
>    Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
>    Dim myDiskFileDestinationOptions As
> CrystalDecisions.Shared.DiskFileDestinationOptions
>
>    Try
>
>      Select Case UniqueFormat
>        Case FileNameFormats.SessionID
>          myExportFile = Session.SessionID.ToString
>        Case FileNameFormats.GUIDDashes
>          myExportFile = System.Guid.NewGuid.ToString("D")
>        Case FileNameFormats.GUIDNoDashes
>          myExportFile = System.Guid.NewGuid.ToString("N")
>      End Select
>
>      myExportFile = System.IO.Path.Combine(GetExportRoot,
> String.Format("PDF_{0}.pdf", myExportFile))
>
>      myDiskFileDestinationOptions = New
> CrystalDecisions.Shared.DiskFileDestinationOptions
>      myDiskFileDestinationOptions.DiskFileName = myExportFile
>
>      myExportOptions = ExportOptions
>
>      With myExportOptions
>        .DestinationOptions = myDiskFileDestinationOptions
>        .ExportDestinationType = .ExportDestinationType.DiskFile
>        .ExportFormatType = .ExportFormatType.PortableDocFormat
>      End With
>
>    Catch ex As Exception
>
>      Dim exc As System.ApplicationException
>      exc = New System.ApplicationException("Unable to prepare export
> options.", ex)
>      Throw exc
>
>    End Try
>
>    Return myExportOptions
>
>  End Function
>
>  Private Function GetExportRoot(ByVal FromApplication As Boolean) As
> String
>
>    Dim strExportRoot As String
>
>    If FromApplication Then
>      Try
>        Application.lock()
>        strExportRoot = Application("ReportExportRoot")
>      Catch ex As Exception
>        Dim exc As ApplicationException
>        exc = New ApplicationException("Unable to lock Web Application for
> read.", ex)
>        Throw exc
>      Finally
>        Application.unlock()
>      End Try
>    Else
>      strExportRoot = Session("ReportExportRoot")
>    End If
>
>    Return strExportRoot
>
>  End Function
>
> #End Region
>
> #Region "Navigation Implementation"
>
>  Private Sub cmdPrint_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles cmdPrint.Click
>
>    Response.ClearContent()
>    Response.ClearHeaders()
>    Response.ContentType = "application/pdf"
>
>    Dim myExportFile As String = CType(Session.Item("exportbestand"),
> String)
>
>    Response.WriteFile(myExportFile)
>    Response.Flush()
>    Response.Close()
>
>    System.IO.File.Delete(myExportFile)
>
>  End Sub
>
>  Private Sub cmdEerste_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles cmdEerste.Click
>    crViewer.ShowFirstPage()
>  End Sub
>
>  Private Sub cmdLaatste_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles cmdLaatste.Click
>    crViewer.ShowLastPage()
>  End Sub
>
>  Private Sub cmdTerug_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles cmdTerug.Click
>    crViewer.ShowPreviousPage()
>  End Sub
>
>  Private Sub cmdVerder_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles cmdVerder.Click
>    crViewer.ShowNextPage()
>  End Sub
>
>  Private Sub drpZoom_SelectedIndexChanged(ByVal sender As Object, ByVal e
> As System.EventArgs) Handles drpZoom.SelectedIndexChanged
>    crViewer.Zoom(drpZoom.SelectedItem.Value)
>  End Sub
>
> #End Region
>
>
> "Alison Givens" <i***@cross-it.nl> wrote in message
> news:%23RW%23bsjNGHA.2124@TK2MSFTNGP14.phx.gbl...
>>> Perhaps you could share your resulting code for comparison?  Did you see
>>> that I suggested the error in your code was
>>>
>>> myReport.SetParameterValue("FiliaalKeuze", 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 CrystalDecisions.CrystalReports.Engine
>> Imports CrystalDecisions.CrystalReports.Engine.ReportDocument
>> Imports CrystalDecisions.Shared
>> Imports System.IO
>>
>>
>> Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles MyBase.Init
>>        'CODEGEN: This method call is required by the Web Form Designer
>>        'Do not modify it using the code editor.
>>        InitializeComponent()
>>
>>
>>
>>        Dim myReport As RapportAIRCOStoringen
>>        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.QueryString("BeginPeriode")
>>            EindPeriode = Request.QueryString("EindPeriode")
>>        Catch ex As Exception
>>            Dim exCustom As ApplicationException
>>            exCustom = New ApplicationException("Unable to parse Query
>> Paramaters.", ex)
>>            Throw exCustom
>>        End Try
>>
>>        'Todo wrap in try
>>        paramField = CreateParameter("FiliaalKeuze")
>>        paramField.CurrentValues.Add(CreateParameterDiscreteValue(2044))
>>        paramField.CurrentValues.Add(CreateParameterDiscreteValue(2344))
>>        myReport.SetParameterValue("FiliaalKeuze", paramField)
>>
>>
>>        'Todo wrap in try
>>        paramField = CreateParameter("Periode")
>>
>> paramField.CurrentValues.Add(CreateParameterRangeValue(BeginPeriode,
>> EindPeriode))
>>        myReport.SetParameterValue("Periode", paramField)
>>
>>
>>        crViewer.ReportSource = myReport
>>
>>
>>        'exporteren to pdf
>>        Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
>>        Dim myDiskFileDestinationOptions As
>> CrystalDecisions.Shared.DiskFileDestinationOptions
>>        Dim myExportFile As String
>>
>>
>>
>>        myExportFile = "\\192.168.2.106\syn2sql$\PDF_" &
>> Session.SessionID.ToString & ".pdf"
>>        myDiskFileDestinationOptions = New
>> CrystalDecisions.Shared.DiskFileDestinationOptions
>>        myDiskFileDestinationOptions.DiskFileName = myExportFile
>>        myExportOptions = myReport.ExportOptions
>>        With myExportOptions
>>            .DestinationOptions = myDiskFileDestinationOptions
>>            .ExportDestinationType = .ExportDestinationType.DiskFile
>>            .ExportFormatType = .ExportFormatType.PortableDocFormat
>>        End With
>>
>>        Try
>>            myReport.Export()
>>        Catch err As Exception
>>            Response.Write("<BR>")
>>            Response.Write(err.Message.ToString)
>>        End Try
>>
>>        Session("exportbestand") = myExportFile
>>    End Sub
>>
>> #End Region
>>
>>    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) 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.EventArgs) Handles cmdPrint.Click
>>        Response.ClearContent()
>>        Response.ClearHeaders()
>>        Response.ContentType = "application/pdf"
>>        Dim myExportFile As String = CType(Session.Item("exportbestand"),
>> String)
>>
>>        Response.WriteFile(myExportFile)
>>        Response.Flush()
>>        Response.Close()
>>
>>        System.IO.File.Delete(myExportFile)
>>    End Sub
>>
>>    Private Function CreateParameter(ByVal ParameterName As String) As
>> ParameterField()
>>        Dim paramField As ParameterField
>>
>>        paramField = New ParameterField
>>        paramField.ParameterFieldName = ParameterName
>>
>>        'Return paramField
>>
>>    End Function
>>
>>    Private Function CreateParameterDiscreteValue(ByVal Value As Object)
>> As ParameterDiscreteValue()
>>
>>        Dim paramDiscreteValue As ParameterDiscreteValue
>>        paramDiscreteValue = New ParameterDiscreteValue
>>        paramDiscreteValue = Value
>>
>>        'Return paramDiscreteValue
>>
>>    End Function
>>
>>    Private Function CreateParameterRangeValue(ByVal StartRange As Object,
>> ByVal EndRange As Object) As ParameterRangeValue
>>        Dim paramRangeValue As ParameterRangeValue
>>
>>        paramRangeValue = New ParameterRangeValue
>>
>>        paramRangeValue.StartValue = StartRange
>>        paramRangeValue.EndValue = EndRange
>>
>>        Return paramRangeValue
>>    End Function
>>
>>
>>    Private Sub cmdEerste_Click(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles cmdEerste.Click
>>        crViewer.ShowFirstPage()
>>    End Sub
>>
>>    Private Sub cmdLaatste_Click(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles cmdLaatste.Click
>>        crViewer.ShowLastPage()
>>    End Sub
>>
>>    Private Sub cmdTerug_Click(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles cmdTerug.Click
>>        crViewer.ShowPreviousPage()
>>    End Sub
>>
>>    Private Sub cmdVerder_Click(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles cmdVerder.Click
>>        crViewer.ShowNextPage()
>>    End Sub
>>
>>    Private Sub drpZoom_SelectedIndexChanged(ByVal sender As Object, ByVal
>> e As System.EventArgs) Handles drpZoom.SelectedIndexChanged
>>        crViewer.Zoom(drpZoom.SelectedItem.Value)
>>    End Sub
>>    Private Sub Page_Unload(ByVal sender As Object, ByVal e As
>> System.EventArgs) Handles MyBase.Unload
>>        Dim myExportFile As String = CType(Session.Item("exportbestand"),
>> String)
>>
>>        System.IO.File.Delete(myExportFile)
>>    End Sub
>> End Class
>>
>>
>>
>>
>>
>>
>>>
>>> "Alison Givens" <i***@cross-it.nl> wrote in message
>>> news:eeEqNEgNGHA.1288@TK2MSFTNGP09.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
>>>> CrystalDecisions.Shared.ParameterField' cannot be converted
>>>> to 'Crystal.Decisions.Shared.ParameterField'
>>>>
>>>> Return paramField
>>>> The text is:
>>>> Value of type 'CrystalDecisions.Shared.ParameterField' cannot be
>>>> converted
>>>> to '1 dimensional array of Crystal.Decisions.Shared.ParameterField'
>>>>
>>>> Same for
>>>> paramField = CreateParamater("Periode")
>>>> Return paramDiscreteValue
>>>>
>>>> Any idea what causes this?
>>>>
>>>> Alison
>>>>
>>>>
>>>> "AMDRIT" <amd***@hotmail.com> wrote in message
>>>> news:urCzE10MGHA.720@TK2MSFTNGP14.phx.gbl...
>>>>> Wow, you do all that for Crystal Reports?  What is
>>>>> RapportAIRCOStoringen?
>>>>>
>>>>>
>>>>> Here is all I do for CR
>>>>>
>>>>> Dim x As CrystalDecisions.CrystalReports.Engine.ReportDocument
>>>>>
>>>>> x.Load(sReportPath) 'Reports are not embedded resources
>>>>> x.SetParameterValue("Paramater1", Paramaters(1))      'Dynamic
>>>>> Paramaters
>>>>> x.SetParameterValue("Paramater2", Paramaters(2))
>>>>> x.SetDataSource(mydata) 'Strongly Typed Datasets
>>>>>
>>>>> Me.CrystalReportViewer1.ReportSource = x
>>>>> Me.CrystalReportViewer1.PrintReport()
>>>>>
>>>>>
>>>>> '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.SetParameterValue("FiliaalKeuze", discreteVal)
>>>>>
>>>>> Why are you setting the crView paramaters and the myReport paramaters?
>>>>>  -->crViewer.ParameterFieldInfo = paramFields
>>>>>  -->myReport.SetParameterValue("Periode", 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 RapportAIRCOStoringen
>>>>>    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.QueryString("BeginPeriode")
>>>>>      EindPeriode = Request.QueryString("EindPeriode")
>>>>>    Catch ex As Exception
>>>>>      Dim exCustom As ApplicationException
>>>>>      exCustom = New ApplicationException("Unable to parse Query
>>>>> Paramaters.", ex)
>>>>>      Throw exCustom
>>>>>    End Try
>>>>>
>>>>>    'Todo wrap in try
>>>>>    paramField = CreateParamater("FiliaalKeuze")
>>>>>    paramField.CurrentValues.Add(CreateParameterDiscreteValue(2044))
>>>>>    paramField.CurrentValues.Add(CreateParameterDiscreteValue(2344))
>>>>>    myReport.SetParameterValue("FiliaalKeuze", paramField)
>>>>>    'paramFields.Add(paramField) --> Not needed
>>>>>
>>>>>    'Todo wrap in try
>>>>>    paramField = CreateParamater("Periode")
>>>>>
>>>>> paramField.CurrentValues.Add(CreateParameterRangeValue(BeginPeriode,
>>>>> EindPeriode))
>>>>>    myReport.SetParameterValue("Periode", paramField)
>>>>>    'paramFields.Add(paramField)--> Not needed
>>>>>
>>>>>    'Todo wrap in try, i don't think you need this
>>>>>    'myReport.SetParameterValue("Periode", rangeVal)
>>>>>    'myReport.SetParameterValue("FiliaalKeuze", discreteVal)
>>>>>
>>>>>    'Todo, determine if we need this step; I don't think you do
>>>>>    'crViewer.ParameterFieldInfo = paramFields
>>>>>
>>>>>    crViewer.ReportSource = myReport
>>>>>
>>>>>  End Sub
>>>>>
>>>>>  Private Function CreateParamater(ByVal ParamaterName As String) As
>>>>> ParameterField
>>>>>    Dim paramField As ParameterField
>>>>>
>>>>>    paramField = New ParameterField
>>>>>    paramField.ParameterFieldName = ParamaterName
>>>>>
>>>>>    Return paramField
>>>>>
>>>>>  End Function
>>>>>
>>>>>  Private Function CreateParameterDiscreteValue(ByVal Value As Object)
>>>>> As ParameterDiscreteValue
>>>>>
>>>>>    Dim paramDiscreteValue As ParameterDiscreteValue
>>>>>    paramDiscreteValue = New ParameterDiscreteValue
>>>>>    paramDiscreteValue = Value
>>>>>
>>>>>    Return paramDiscreteValue
>>>>>
>>>>>  End Function
>>>>>
>>>>>  Private Function CreateParameterRangeValue(ByVal StartRange As
>>>>> Object, ByVal EndRange As Object) As ParameterRangeValue
>>>>>    Dim paramRangeValue As ParameterRangeValue
>>>>>
>>>>>    paramRangeValue = New ParameterRangeValue
>>>>>
>>>>>    paramRangeValue.StartValue = StartRange
>>>>>    paramRangeValue.EndValue = EndRange
>>>>>
>>>>>    Return paramRangeValue
>>>>>  End Function
>>>>>
>>>>> "Alison Givens" <i***@cross-it.nl> wrote in message
>>>>> news:eW4b66tMGHA.668@TK2MSFTNGP11.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.QueryString("BeginPeriode")
>>>>>> EindPeriode = Request.QueryString("EindPeriode")
>>>>>>
>>>>>> Dim myReport As New RapportAIRCOStoringen
>>>>>>
>>>>>> Dim paramFields As New ParameterFields
>>>>>> Dim paramField As New ParameterField
>>>>>> Dim discreteVal As New ParameterDiscreteValue
>>>>>> Dim rangeVal As New ParameterRangeValue
>>>>>>
>>>>>> paramField.ParameterFieldName = "FiliaalKeuze"
>>>>>> discreteVal.Value = "2044"
>>>>>> paramField.CurrentValues.Add(discreteVal)
>>>>>>
>>>>>> discreteVal = New ParameterDiscreteValue
>>>>>> discreteVal.Value = "2344"
>>>>>> paramField.CurrentValues.Add(discreteVal)
>>>>>>
>>>>>> paramFields.Add(paramField)
>>>>>>
>>>>>> paramField = New ParameterField
>>>>>>
>>>>>> paramField.ParameterFieldName = "Periode"
>>>>>>
>>>>>> rangeVal.StartValue = BeginPeriode
>>>>>> rangeVal.EndValue = EindPeriode
>>>>>> paramField.CurrentValues.Add(rangeVal)
>>>>>>
>>>>>> paramFields.Add(paramField)
>>>>>>
>>>>>> crViewer.ParameterFieldInfo = paramFields
>>>>>> myReport.SetParameterValue("Periode", rangeVal)
>>>>>> myReport.SetParameterValue("FiliaalKeuze", discreteVal)
>>>>>> crViewer.ReportSource = myReport
>>>>>>
>>>>>> As you can see I use myReport.SetParameterValue 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
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
Author
21 Feb 2006 3:57 PM
AMDRIT
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(KeyName)

2.   Correct the line
        myExportFile = System.IO.Path.Combine(GetExportRoot,
String.Format("PDF_{0}.pdf", myExportFile))
       to
         myExportFile = System.IO.Path.Combine(GetExportRoot(false),
String.Format("PDF_{0}.pdf", myExportFile))
       or
         myExportFile = System.IO.Path.Combine(GetExportRoot(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 ReportExportRoot in
Application_OnStart, 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="ReportExportRoot" Value = "\\192.168.2.106\syn2sql$\PDF_" />
for more information on appsettings see:
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/cpgenref/html/gngrfappsettingselement.htm

in your application's global.asax on Application_OnStart
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/vbcon/html/vbconPageApplicationContext.htm
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/cpguide/html/cpcontheglobalasaxfile.htm

sub application_onstart()
  Dim ReportExportRoot as string
  ReportExportRoot =
System.Configuration.ConfigurationSettings.AppSettings("ReportExportRoot")
  Application.Lock
    Application("ReportExportRoot") = ReportExportRoot
  Application.Unlock
end sub

in you application's global.asax on Session_OnStart
sub Session_Onstart()
  Dim ReportExportRoot as string
  Application.Lock
    ReportExportRoot = ctype(Application("ReportExportRoot"),string)
  Application.Unlock
  Session.item("ReportExportRoot") = ReportExportRoot
end sub

Show quoteHide quote
"Alison Givens" <i***@cross-it.nl> wrote in message
news:OTYvuJsNGHA.3164@TK2MSFTNGP11.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(GetExportRoot,
> String.Format("PDF_{0}.pdf", myExportFile))
> Says:Argument not specified for parameter 'FromApplication' of
> 'Private Function GetExportRoot(FromApplication 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.EventArgs) Handles MyBase.Init
>        'CODEGEN: This method call is required by the Web Form Designer
>        'Do not modify it using the code editor.
>        InitializeComponent()
>        Dim myReport As RapportAIRCOStoringen
>        Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
>
>        Try
>
>            Try
>                PrepareReport(myReport)
>            Catch ex As Exception
>                Dim exc As ApplicationException
>                exc = New ApplicationException("Unable to prepare report.",
> ex)
>                Throw exc
>            End Try
>
>            Try
>                'exporteren to pdf
>                myExportOptions =
> GetExportOptions(FileNameFormats.GUIDNoDashes, CType(myReport,
> CrystalDecisions.CrystalReports.Engine.ReportDocument).ExportOptions)
>                myReport.Export()
>
>            Catch ex As Exception
>                Dim exc As ApplicationException
>                exc = New ApplicationException("Unable to export report.",
> ex)
>                Throw exc
>            End Try
>
>            crViewer.ReportSource = myReport
>
>            Session("exportbestand") =
> CType(myExportOptions.DestinationOptions,
> CrystalDecisions.Shared.DiskFileDestinationOptions).DiskFileName
>
>        Catch err As Exception
>            Response.Write("<BR>")
>            Response.Write(err.Message.ToString)
>        End Try
>
>
>
>
>    End Sub
>
> #End Region
>
> #Region "Page Implementation"
>
>    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
>        'Put user code to initialize the page here
>    End Sub
>
>    Private Sub Page_Unload(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles MyBase.Unload
>        Dim myExportFile As String = CType(Session.Item("exportbestand"),
> String)
>
>        System.IO.File.Delete(myExportFile)
>    End Sub
>
> #End Region
>
> #Region "Report Setup"
>
>    Private Sub PrepareReport(ByVal myReport As
> CrystalDecisions.CrystalReports.Engine.ReportDocument)
>
>        Dim paramFields As ParameterFields
>        Dim paramField As ParameterField
>
>        Const SessionExecption As String = "Unable to read session
> objects."
>
>        Try
>
>            paramFields = New ParameterFields
>            Try
>                paramField = CreateParameter("FiliaalKeuze")
>
> paramField.CurrentValues.Add(CreateParameterDiscreteValue(GetSessionValue("DiscreteValue1")))
>
> paramField.CurrentValues.Add(CreateParameterDiscreteValue(GetSessionValue("DiscreteValue1")))
>
>            Catch ex As Exception
>                Dim exc As System.ApplicationException
>                exc = New System.ApplicationException(SessionExecption, ex)
>                Throw exc
>            End Try
>
>            myReport.SetParameterValue("FiliaalKeuze", paramField)
>
>            Try
>                'Todo wrap in try
>                paramField = CreateParameter("Periode")
>
> paramField.CurrentValues.Add(CreateParameterRangeValue(GetSessionValue("BeginPeriode"),
> GetSessionValue("EindPeriode")))
>            Catch ex As Exception
>                Dim exc As System.ApplicationException
>                exc = New System.ApplicationException(SessionExecption, ex)
>                Throw exc
>            End Try
>
>            myReport.SetParameterValue("Periode", paramField)
>
>        Catch ex As Exception
>
>            Dim exc As System.ApplicationException
>            exc = New System.ApplicationException("Unable 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.ParameterFieldName = ParameterName
>
>        Return paramField
>
>    End Function
>
>    Private Function CreateParameterDiscreteValue(ByVal Value As Object) As
> ParameterDiscreteValue
>
>        Dim paramDiscreteValue As ParameterDiscreteValue
>        paramDiscreteValue = New ParameterDiscreteValue
>        paramDiscreteValue = Value
>
>        Return paramDiscreteValue
>
>    End Function
>
>    Private Function CreateParameterRangeValue(ByVal StartRange As Object,
> ByVal EndRange As Object) As ParameterRangeValue
>        Dim paramRangeValue As ParameterRangeValue
>
>        paramRangeValue = New ParameterRangeValue
>
>        paramRangeValue.StartValue = StartRange
>        paramRangeValue.EndValue = EndRange
>
>        Return paramRangeValue
>    End Function
>
> #End Region
>
> #Region "Report Export"
>
>    Private Function GetExportOptions(ByVal UniqueFormat As
> FileNameFormats, ByVal ExportOptions As
> CrystalDecisions.Shared.ExportOptions) As
> CrystalDecisions.Shared.ExportOptions
>
>        Dim myExportFile As String
>        Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
>        Dim myDiskFileDestinationOptions As
> CrystalDecisions.Shared.DiskFileDestinationOptions
>
>        Try
>
>            Select Case UniqueFormat
>                Case FileNameFormats.SessionID
>                    myExportFile = Session.SessionID.ToString
>                Case FileNameFormats.GUIDDashes
>                    myExportFile = System.Guid.NewGuid.ToString("D")
>                Case FileNameFormats.GUIDNoDashes
>                    myExportFile = System.Guid.NewGuid.ToString("N")
>            End Select
>
>            myExportFile = System.IO.Path.Combine(GetExportRoot,
> String.Format("PDF_{0}.pdf", myExportFile))
>
>            myDiskFileDestinationOptions = New
> CrystalDecisions.Shared.DiskFileDestinationOptions
>            myDiskFileDestinationOptions.DiskFileName = myExportFile
>
>            myExportOptions = ExportOptions
>
>            With myExportOptions
>                .DestinationOptions = myDiskFileDestinationOptions
>                .ExportDestinationType = .ExportDestinationType.DiskFile
>                .ExportFormatType = .ExportFormatType.PortableDocFormat
>            End With
>
>        Catch ex As Exception
>
>            Dim exc As System.ApplicationException
>            exc = New System.ApplicationException("Unable to prepare export
> options.", ex)
>            Throw exc
>
>        End Try
>
>        Return myExportOptions
>
>    End Function
>
>    Private Function GetExportRoot(ByVal FromApplication As Boolean) As
> String
>
>        Dim strExportRoot As String
>
>        If FromApplication Then
>            Try
>                Application.Lock()
>                strExportRoot = Application("ReportExportRoot")
>            Catch ex As Exception
>                Dim exc As ApplicationException
>                exc = New ApplicationException("Unable to lock Web
> Application for read.", ex)
>                Throw exc
>            Finally
>                Application.UnLock()
>            End Try
>        Else
>            strExportRoot = Session("ReportExportRoot")
>        End If
>
>        Return strExportRoot
>
>    End Function
>
> #End Region
>
> #Region "Navigation Implementation"
>
>    Private Sub cmdPrint_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles cmdPrint.Click
>
>        Response.ClearContent()
>        Response.ClearHeaders()
>        Response.ContentType = "application/pdf"
>
>        Dim myExportFile As String = CType(Session.Item("exportbestand"),
> String)
>
>        Response.WriteFile(myExportFile)
>        Response.Flush()
>        Response.Close()
>
>        System.IO.File.Delete(myExportFile)
>
>    End Sub
>
>    Private Sub cmdEerste_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles cmdEerste.Click
>        crViewer.ShowFirstPage()
>    End Sub
>
>    Private Sub cmdLaatste_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles cmdLaatste.Click
>        crViewer.ShowLastPage()
>    End Sub
>
>    Private Sub cmdTerug_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles cmdTerug.Click
>        crViewer.ShowPreviousPage()
>    End Sub
>
>    Private Sub cmdVerder_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles cmdVerder.Click
>        crViewer.ShowNextPage()
>    End Sub
>
>  Private Sub drpZoom_SelectedIndexChanged(ByVal sender As Object, ByVal e
> As System.EventArgs) Handles drpZoom.SelectedIndexChanged
>        crViewer.Zoom(drpZoom.SelectedItem.Value)
>    End Sub
>
> #End Region
>
>
> End Class
>
>
>
>
> "AMDRIT" <amd***@hotmail.com> wrote in message
> news:OpMDndkNGHA.2064@TK2MSFTNGP09.phx.gbl...
>> Ok, first the isue you were having with the "Blue lines" is:
>>
>> Private Function CreateParameterDiscreteValue(ByVal Value As Object) As
>> ParameterDiscreteValue()
>> -->        Retun type is expecting an array of ParameterDiscreteValue
>>
>> it should be
>>
>> Private Function CreateParameterDiscreteValue(ByVal Value As Object) As
>> ParameterDiscreteValue
>> -->        Retun type is expecting an single ParameterDiscreteValue
>>
>> 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.EventArgs) Handles MyBase.Init
>>    'CODEGEN: This method call is required by the Web Form Designer
>>    'Do not modify it using the code editor.
>>    InitializeComponent()
>>
>>    Dim myReport As RapportAIRCOStoringen
>>    Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
>>
>>    Try
>>
>>      Try
>>        PrepareReport(myReport)
>>      Catch ex As Exception
>>        Dim exc As ApplicationException
>>        exc = New ApplicationException("Unable to prepare report.", ex)
>>        Throw exc
>>      End Try
>>
>>      Try
>>        'exporteren to pdf
>>        myExportOptions = GetExportOptions(FileNameFormats.GUIDNoDashes,
>> CType(myReport,
>> CrystalDecisions.CrystalReports.Engine.ReportDocument).ExportOptions)
>>        myReport.Export()
>>
>>      Catch ex As Exception
>>        Dim exc As ApplicationException
>>        exc = New ApplicationException("Unable to export report.", ex)
>>        Throw exc
>>      End Try
>>
>>      crViewer.ReportSource = myReport
>>
>>      Session("exportbestand") = CType(myExportOptions.DestinationOptions,
>> CrystalDecisions.Shared.DiskFileDestinationOptions).DiskFileName
>>
>>    Catch err As Exception
>>      Response.Write("<BR>")
>>      Response.Write(err.Message.ToString)
>>    End Try
>>
>>  End Sub
>>
>> #Region "Page Implementation"
>>
>>  Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles MyBase.Load
>>    'Put user code to initialize the page here
>>  End Sub
>>
>>  Private Sub Page_Unload(ByVal sender As Object, ByVal e As
>> System.EventArgs) Handles MyBase.Unload
>>    Dim myExportFile As String = CType(Session.Item("exportbestand"),
>> String)
>>
>>    System.IO.File.Delete(myExportFile)
>>  End Sub
>>
>> #End Region
>>
>> #Region "Report Setup"
>>
>>  Private Sub PrepareReport(ByVal myReport As
>> CrystalDecisions.CrystalReports.Engine.ReportDocument)
>>
>>    Dim paramFields As ParameterFields
>>    Dim paramField As ParameterField
>>
>>    Const SessionExecption As String = "Unable to read session objects."
>>
>>    Try
>>
>>      paramFields = New ParameterFields
>>      Try
>>        paramField = CreateParameter("FiliaalKeuze")
>>
>> paramField.CurrentValues.Add(CreateParameterDiscreteValue(GetSessionValue("DiscreteValue1")))
>>
>> paramField.CurrentValues.Add(CreateParameterDiscreteValue(GetSessionValue("DiscreteValue1")))
>>      Catch ex As Exception
>>        Dim exc As System.ApplicationException
>>        exc = New System.ApplicationException(SessionExecption, ex)
>>        Throw exc
>>      End Try
>>
>>      myReport.SetParameterValue("FiliaalKeuze", paramField)
>>
>>      Try
>>        'Todo wrap in try
>>        paramField = CreateParameter("Periode")
>>
>> paramField.CurrentValues.Add(CreateParameterRangeValue(GetSessionValue("BeginPeriode"),
>> GetSessionValue("EindPeriode")))
>>      Catch ex As Exception
>>        Dim exc As System.ApplicationException
>>        exc = New System.ApplicationException(SessionExecption, ex)
>>        Throw exc
>>      End Try
>>
>>      myReport.SetParameterValue("Periode", paramField)
>>
>>    Catch ex As Exception
>>
>>      Dim exc As System.ApplicationException
>>      exc = New System.ApplicationException("Unable 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.ParameterFieldName = ParameterName
>>
>>    Return paramField
>>
>>  End Function
>>
>>  Private Function CreateParameterDiscreteValue(ByVal Value As Object) As
>> ParameterDiscreteValue()
>>
>>    Dim paramDiscreteValue As ParameterDiscreteValue
>>    paramDiscreteValue = New ParameterDiscreteValue
>>    paramDiscreteValue = Value
>>
>>    'Return paramDiscreteValue
>>
>>  End Function
>>
>>  Private Function CreateParameterRangeValue(ByVal StartRange As Object,
>> ByVal EndRange As Object) As ParameterRangeValue
>>    Dim paramRangeValue As ParameterRangeValue
>>
>>    paramRangeValue = New ParameterRangeValue
>>
>>    paramRangeValue.StartValue = StartRange
>>    paramRangeValue.EndValue = EndRange
>>
>>    Return paramRangeValue
>>  End Function
>>
>> #End Region
>>
>> #Region "Report Export"
>>
>>  Private Function GetExportOptions(ByVal UniqueFormat As FileNameFormats,
>> ByVal ExportOptions As CrystalDecisions.Shared.ExportOptions) As
>> CrystalDecisions.Shared.ExportOptions
>>
>>    Dim myExportFile As String
>>    Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
>>    Dim myDiskFileDestinationOptions As
>> CrystalDecisions.Shared.DiskFileDestinationOptions
>>
>>    Try
>>
>>      Select Case UniqueFormat
>>        Case FileNameFormats.SessionID
>>          myExportFile = Session.SessionID.ToString
>>        Case FileNameFormats.GUIDDashes
>>          myExportFile = System.Guid.NewGuid.ToString("D")
>>        Case FileNameFormats.GUIDNoDashes
>>          myExportFile = System.Guid.NewGuid.ToString("N")
>>      End Select
>>
>>      myExportFile = System.IO.Path.Combine(GetExportRoot,
>> String.Format("PDF_{0}.pdf", myExportFile))
>>
>>      myDiskFileDestinationOptions = New
>> CrystalDecisions.Shared.DiskFileDestinationOptions
>>      myDiskFileDestinationOptions.DiskFileName = myExportFile
>>
>>      myExportOptions = ExportOptions
>>
>>      With myExportOptions
>>        .DestinationOptions = myDiskFileDestinationOptions
>>        .ExportDestinationType = .ExportDestinationType.DiskFile
>>        .ExportFormatType = .ExportFormatType.PortableDocFormat
>>      End With
>>
>>    Catch ex As Exception
>>
>>      Dim exc As System.ApplicationException
>>      exc = New System.ApplicationException("Unable to prepare export
>> options.", ex)
>>      Throw exc
>>
>>    End Try
>>
>>    Return myExportOptions
>>
>>  End Function
>>
>>  Private Function GetExportRoot(ByVal FromApplication As Boolean) As
>> String
>>
>>    Dim strExportRoot As String
>>
>>    If FromApplication Then
>>      Try
>>        Application.lock()
>>        strExportRoot = Application("ReportExportRoot")
>>      Catch ex As Exception
>>        Dim exc As ApplicationException
>>        exc = New ApplicationException("Unable to lock Web Application for
>> read.", ex)
>>        Throw exc
>>      Finally
>>        Application.unlock()
>>      End Try
>>    Else
>>      strExportRoot = Session("ReportExportRoot")
>>    End If
>>
>>    Return strExportRoot
>>
>>  End Function
>>
>> #End Region
>>
>> #Region "Navigation Implementation"
>>
>>  Private Sub cmdPrint_Click(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles cmdPrint.Click
>>
>>    Response.ClearContent()
>>    Response.ClearHeaders()
>>    Response.ContentType = "application/pdf"
>>
>>    Dim myExportFile As String = CType(Session.Item("exportbestand"),
>> String)
>>
>>    Response.WriteFile(myExportFile)
>>    Response.Flush()
>>    Response.Close()
>>
>>    System.IO.File.Delete(myExportFile)
>>
>>  End Sub
>>
>>  Private Sub cmdEerste_Click(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles cmdEerste.Click
>>    crViewer.ShowFirstPage()
>>  End Sub
>>
>>  Private Sub cmdLaatste_Click(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles cmdLaatste.Click
>>    crViewer.ShowLastPage()
>>  End Sub
>>
>>  Private Sub cmdTerug_Click(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles cmdTerug.Click
>>    crViewer.ShowPreviousPage()
>>  End Sub
>>
>>  Private Sub cmdVerder_Click(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles cmdVerder.Click
>>    crViewer.ShowNextPage()
>>  End Sub
>>
>>  Private Sub drpZoom_SelectedIndexChanged(ByVal sender As Object, ByVal e
>> As System.EventArgs) Handles drpZoom.SelectedIndexChanged
>>    crViewer.Zoom(drpZoom.SelectedItem.Value)
>>  End Sub
>>
>> #End Region
>>
>>
>> "Alison Givens" <i***@cross-it.nl> wrote in message
>> news:%23RW%23bsjNGHA.2124@TK2MSFTNGP14.phx.gbl...
>>>> Perhaps you could share your resulting code for comparison?  Did you
>>>> see that I suggested the error in your code was
>>>>
>>>> myReport.SetParameterValue("FiliaalKeuze", 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 CrystalDecisions.CrystalReports.Engine
>>> Imports CrystalDecisions.CrystalReports.Engine.ReportDocument
>>> Imports CrystalDecisions.Shared
>>> Imports System.IO
>>>
>>>
>>> Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
>>> System.EventArgs) Handles MyBase.Init
>>>        'CODEGEN: This method call is required by the Web Form Designer
>>>        'Do not modify it using the code editor.
>>>        InitializeComponent()
>>>
>>>
>>>
>>>        Dim myReport As RapportAIRCOStoringen
>>>        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.QueryString("BeginPeriode")
>>>            EindPeriode = Request.QueryString("EindPeriode")
>>>        Catch ex As Exception
>>>            Dim exCustom As ApplicationException
>>>            exCustom = New ApplicationException("Unable to parse Query
>>> Paramaters.", ex)
>>>            Throw exCustom
>>>        End Try
>>>
>>>        'Todo wrap in try
>>>        paramField = CreateParameter("FiliaalKeuze")
>>>        paramField.CurrentValues.Add(CreateParameterDiscreteValue(2044))
>>>        paramField.CurrentValues.Add(CreateParameterDiscreteValue(2344))
>>>        myReport.SetParameterValue("FiliaalKeuze", paramField)
>>>
>>>
>>>        'Todo wrap in try
>>>        paramField = CreateParameter("Periode")
>>>
>>> paramField.CurrentValues.Add(CreateParameterRangeValue(BeginPeriode,
>>> EindPeriode))
>>>        myReport.SetParameterValue("Periode", paramField)
>>>
>>>
>>>        crViewer.ReportSource = myReport
>>>
>>>
>>>        'exporteren to pdf
>>>        Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
>>>        Dim myDiskFileDestinationOptions As
>>> CrystalDecisions.Shared.DiskFileDestinationOptions
>>>        Dim myExportFile As String
>>>
>>>
>>>
>>>        myExportFile = "\\192.168.2.106\syn2sql$\PDF_" &
>>> Session.SessionID.ToString & ".pdf"
>>>        myDiskFileDestinationOptions = New
>>> CrystalDecisions.Shared.DiskFileDestinationOptions
>>>        myDiskFileDestinationOptions.DiskFileName = myExportFile
>>>        myExportOptions = myReport.ExportOptions
>>>        With myExportOptions
>>>            .DestinationOptions = myDiskFileDestinationOptions
>>>            .ExportDestinationType = .ExportDestinationType.DiskFile
>>>            .ExportFormatType = .ExportFormatType.PortableDocFormat
>>>        End With
>>>
>>>        Try
>>>            myReport.Export()
>>>        Catch err As Exception
>>>            Response.Write("<BR>")
>>>            Response.Write(err.Message.ToString)
>>>        End Try
>>>
>>>        Session("exportbestand") = myExportFile
>>>    End Sub
>>>
>>> #End Region
>>>
>>>    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
>>> System.EventArgs) 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.EventArgs) Handles cmdPrint.Click
>>>        Response.ClearContent()
>>>        Response.ClearHeaders()
>>>        Response.ContentType = "application/pdf"
>>>        Dim myExportFile As String = CType(Session.Item("exportbestand"),
>>> String)
>>>
>>>        Response.WriteFile(myExportFile)
>>>        Response.Flush()
>>>        Response.Close()
>>>
>>>        System.IO.File.Delete(myExportFile)
>>>    End Sub
>>>
>>>    Private Function CreateParameter(ByVal ParameterName As String) As
>>> ParameterField()
>>>        Dim paramField As ParameterField
>>>
>>>        paramField = New ParameterField
>>>        paramField.ParameterFieldName = ParameterName
>>>
>>>        'Return paramField
>>>
>>>    End Function
>>>
>>>    Private Function CreateParameterDiscreteValue(ByVal Value As Object)
>>> As ParameterDiscreteValue()
>>>
>>>        Dim paramDiscreteValue As ParameterDiscreteValue
>>>        paramDiscreteValue = New ParameterDiscreteValue
>>>        paramDiscreteValue = Value
>>>
>>>        'Return paramDiscreteValue
>>>
>>>    End Function
>>>
>>>    Private Function CreateParameterRangeValue(ByVal StartRange As
>>> Object, ByVal EndRange As Object) As ParameterRangeValue
>>>        Dim paramRangeValue As ParameterRangeValue
>>>
>>>        paramRangeValue = New ParameterRangeValue
>>>
>>>        paramRangeValue.StartValue = StartRange
>>>        paramRangeValue.EndValue = EndRange
>>>
>>>        Return paramRangeValue
>>>    End Function
>>>
>>>
>>>    Private Sub cmdEerste_Click(ByVal sender As System.Object, ByVal e As
>>> System.EventArgs) Handles cmdEerste.Click
>>>        crViewer.ShowFirstPage()
>>>    End Sub
>>>
>>>    Private Sub cmdLaatste_Click(ByVal sender As System.Object, ByVal e
>>> As System.EventArgs) Handles cmdLaatste.Click
>>>        crViewer.ShowLastPage()
>>>    End Sub
>>>
>>>    Private Sub cmdTerug_Click(ByVal sender As System.Object, ByVal e As
>>> System.EventArgs) Handles cmdTerug.Click
>>>        crViewer.ShowPreviousPage()
>>>    End Sub
>>>
>>>    Private Sub cmdVerder_Click(ByVal sender As System.Object, ByVal e As
>>> System.EventArgs) Handles cmdVerder.Click
>>>        crViewer.ShowNextPage()
>>>    End Sub
>>>
>>>    Private Sub drpZoom_SelectedIndexChanged(ByVal sender As Object,
>>> ByVal e As System.EventArgs) Handles drpZoom.SelectedIndexChanged
>>>        crViewer.Zoom(drpZoom.SelectedItem.Value)
>>>    End Sub
>>>    Private Sub Page_Unload(ByVal sender As Object, ByVal e As
>>> System.EventArgs) Handles MyBase.Unload
>>>        Dim myExportFile As String = CType(Session.Item("exportbestand"),
>>> String)
>>>
>>>        System.IO.File.Delete(myExportFile)
>>>    End Sub
>>> End Class
>>>
>>>
>>>
>>>
>>>
>>>
>>>>
>>>> "Alison Givens" <i***@cross-it.nl> wrote in message
>>>> news:eeEqNEgNGHA.1288@TK2MSFTNGP09.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
>>>>> CrystalDecisions.Shared.ParameterField' cannot be converted
>>>>> to 'Crystal.Decisions.Shared.ParameterField'
>>>>>
>>>>> Return paramField
>>>>> The text is:
>>>>> Value of type 'CrystalDecisions.Shared.ParameterField' cannot be
>>>>> converted
>>>>> to '1 dimensional array of Crystal.Decisions.Shared.ParameterField'
>>>>>
>>>>> Same for
>>>>> paramField = CreateParamater("Periode")
>>>>> Return paramDiscreteValue
>>>>>
>>>>> Any idea what causes this?
>>>>>
>>>>> Alison
>>>>>
>>>>>
>>>>> "AMDRIT" <amd***@hotmail.com> wrote in message
>>>>> news:urCzE10MGHA.720@TK2MSFTNGP14.phx.gbl...
>>>>>> Wow, you do all that for Crystal Reports?  What is
>>>>>> RapportAIRCOStoringen?
>>>>>>
>>>>>>
>>>>>> Here is all I do for CR
>>>>>>
>>>>>> Dim x As CrystalDecisions.CrystalReports.Engine.ReportDocument
>>>>>>
>>>>>> x.Load(sReportPath) 'Reports are not embedded resources
>>>>>> x.SetParameterValue("Paramater1", Paramaters(1))      'Dynamic
>>>>>> Paramaters
>>>>>> x.SetParameterValue("Paramater2", Paramaters(2))
>>>>>> x.SetDataSource(mydata) 'Strongly Typed Datasets
>>>>>>
>>>>>> Me.CrystalReportViewer1.ReportSource = x
>>>>>> Me.CrystalReportViewer1.PrintReport()
>>>>>>
>>>>>>
>>>>>> '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.SetParameterValue("FiliaalKeuze", discreteVal)
>>>>>>
>>>>>> Why are you setting the crView paramaters and the myReport
>>>>>> paramaters?
>>>>>>  -->crViewer.ParameterFieldInfo = paramFields
>>>>>>  -->myReport.SetParameterValue("Periode", 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 RapportAIRCOStoringen
>>>>>>    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.QueryString("BeginPeriode")
>>>>>>      EindPeriode = Request.QueryString("EindPeriode")
>>>>>>    Catch ex As Exception
>>>>>>      Dim exCustom As ApplicationException
>>>>>>      exCustom = New ApplicationException("Unable to parse Query
>>>>>> Paramaters.", ex)
>>>>>>      Throw exCustom
>>>>>>    End Try
>>>>>>
>>>>>>    'Todo wrap in try
>>>>>>    paramField = CreateParamater("FiliaalKeuze")
>>>>>>    paramField.CurrentValues.Add(CreateParameterDiscreteValue(2044))
>>>>>>    paramField.CurrentValues.Add(CreateParameterDiscreteValue(2344))
>>>>>>    myReport.SetParameterValue("FiliaalKeuze", paramField)
>>>>>>    'paramFields.Add(paramField) --> Not needed
>>>>>>
>>>>>>    'Todo wrap in try
>>>>>>    paramField = CreateParamater("Periode")
>>>>>>
>>>>>> paramField.CurrentValues.Add(CreateParameterRangeValue(BeginPeriode,
>>>>>> EindPeriode))
>>>>>>    myReport.SetParameterValue("Periode", paramField)
>>>>>>    'paramFields.Add(paramField)--> Not needed
>>>>>>
>>>>>>    'Todo wrap in try, i don't think you need this
>>>>>>    'myReport.SetParameterValue("Periode", rangeVal)
>>>>>>    'myReport.SetParameterValue("FiliaalKeuze", discreteVal)
>>>>>>
>>>>>>    'Todo, determine if we need this step; I don't think you do
>>>>>>    'crViewer.ParameterFieldInfo = paramFields
>>>>>>
>>>>>>    crViewer.ReportSource = myReport
>>>>>>
>>>>>>  End Sub
>>>>>>
>>>>>>  Private Function CreateParamater(ByVal ParamaterName As String) As
>>>>>> ParameterField
>>>>>>    Dim paramField As ParameterField
>>>>>>
>>>>>>    paramField = New ParameterField
>>>>>>    paramField.ParameterFieldName = ParamaterName
>>>>>>
>>>>>>    Return paramField
>>>>>>
>>>>>>  End Function
>>>>>>
>>>>>>  Private Function CreateParameterDiscreteValue(ByVal Value As Object)
>>>>>> As ParameterDiscreteValue
>>>>>>
>>>>>>    Dim paramDiscreteValue As ParameterDiscreteValue
>>>>>>    paramDiscreteValue = New ParameterDiscreteValue
>>>>>>    paramDiscreteValue = Value
>>>>>>
>>>>>>    Return paramDiscreteValue
>>>>>>
>>>>>>  End Function
>>>>>>
>>>>>>  Private Function CreateParameterRangeValue(ByVal StartRange As
>>>>>> Object, ByVal EndRange As Object) As ParameterRangeValue
>>>>>>    Dim paramRangeValue As ParameterRangeValue
>>>>>>
>>>>>>    paramRangeValue = New ParameterRangeValue
>>>>>>
>>>>>>    paramRangeValue.StartValue = StartRange
>>>>>>    paramRangeValue.EndValue = EndRange
>>>>>>
>>>>>>    Return paramRangeValue
>>>>>>  End Function
>>>>>>
>>>>>> "Alison Givens" <i***@cross-it.nl> wrote in message
>>>>>> news:eW4b66tMGHA.668@TK2MSFTNGP11.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.QueryString("BeginPeriode")
>>>>>>> EindPeriode = Request.QueryString("EindPeriode")
>>>>>>>
>>>>>>> Dim myReport As New RapportAIRCOStoringen
>>>>>>>
>>>>>>> Dim paramFields As New ParameterFields
>>>>>>> Dim paramField As New ParameterField
>>>>>>> Dim discreteVal As New ParameterDiscreteValue
>>>>>>> Dim rangeVal As New ParameterRangeValue
>>>>>>>
>>>>>>> paramField.ParameterFieldName = "FiliaalKeuze"
>>>>>>> discreteVal.Value = "2044"
>>>>>>> paramField.CurrentValues.Add(discreteVal)
>>>>>>>
>>>>>>> discreteVal = New ParameterDiscreteValue
>>>>>>> discreteVal.Value = "2344"
>>>>>>> paramField.CurrentValues.Add(discreteVal)
>>>>>>>
>>>>>>> paramFields.Add(paramField)
>>>>>>>
>>>>>>> paramField = New ParameterField
>>>>>>>
>>>>>>> paramField.ParameterFieldName = "Periode"
>>>>>>>
>>>>>>> rangeVal.StartValue = BeginPeriode
>>>>>>> rangeVal.EndValue = EindPeriode
>>>>>>> paramField.CurrentValues.Add(rangeVal)
>>>>>>>
>>>>>>> paramFields.Add(paramField)
>>>>>>>
>>>>>>> crViewer.ParameterFieldInfo = paramFields
>>>>>>> myReport.SetParameterValue("Periode", rangeVal)
>>>>>>> myReport.SetParameterValue("FiliaalKeuze", discreteVal)
>>>>>>> crViewer.ReportSource = myReport
>>>>>>>
>>>>>>> As you can see I use myReport.SetParameterValue 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
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
Author
22 Feb 2006 8:10 AM
Alison Givens
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:  <configuration>
Line 3:      <appSettings>
Line 4:    <Add key="ReportExportRoot" Value
="\\192.168.2.106\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(KeyName)
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






Show quoteHide quote
"AMDRIT" <amd***@hotmail.com> wrote in message
news:OYjEf9vNGHA.532@TK2MSFTNGP15.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(KeyName)
>
> 2.   Correct the line
>        myExportFile = System.IO.Path.Combine(GetExportRoot,
> String.Format("PDF_{0}.pdf", myExportFile))
>       to
>         myExportFile = System.IO.Path.Combine(GetExportRoot(false),
> String.Format("PDF_{0}.pdf", myExportFile))
>       or
>         myExportFile = System.IO.Path.Combine(GetExportRoot(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 ReportExportRoot in
> Application_OnStart, 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="ReportExportRoot" Value = "\\192.168.2.106\syn2sql$\PDF_" />
> for more information on appsettings see:
> ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/cpgenref/html/gngrfappsettingselement.htm
>
> in your application's global.asax on Application_OnStart
> ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/vbcon/html/vbconPageApplicationContext.htm
> ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/cpguide/html/cpcontheglobalasaxfile.htm
>
> sub application_onstart()
>  Dim ReportExportRoot as string
>  ReportExportRoot =
> System.Configuration.ConfigurationSettings.AppSettings("ReportExportRoot")
>  Application.Lock
>    Application("ReportExportRoot") = ReportExportRoot
>  Application.Unlock
> end sub
>
> in you application's global.asax on Session_OnStart
> sub Session_Onstart()
>  Dim ReportExportRoot as string
>  Application.Lock
>    ReportExportRoot = ctype(Application("ReportExportRoot"),string)
>  Application.Unlock
>  Session.item("ReportExportRoot") = ReportExportRoot
> end sub
>
> "Alison Givens" <i***@cross-it.nl> wrote in message
> news:OTYvuJsNGHA.3164@TK2MSFTNGP11.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(GetExportRoot,
>> String.Format("PDF_{0}.pdf", myExportFile))
>> Says:Argument not specified for parameter 'FromApplication' of
>> 'Private Function GetExportRoot(FromApplication 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.EventArgs) Handles MyBase.Init
>>        'CODEGEN: This method call is required by the Web Form Designer
>>        'Do not modify it using the code editor.
>>        InitializeComponent()
>>        Dim myReport As RapportAIRCOStoringen
>>        Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
>>
>>        Try
>>
>>            Try
>>                PrepareReport(myReport)
>>            Catch ex As Exception
>>                Dim exc As ApplicationException
>>                exc = New ApplicationException("Unable to prepare
>> report.", ex)
>>                Throw exc
>>            End Try
>>
>>            Try
>>                'exporteren to pdf
>>                myExportOptions =
>> GetExportOptions(FileNameFormats.GUIDNoDashes, CType(myReport,
>> CrystalDecisions.CrystalReports.Engine.ReportDocument).ExportOptions)
>>                myReport.Export()
>>
>>            Catch ex As Exception
>>                Dim exc As ApplicationException
>>                exc = New ApplicationException("Unable to export report.",
>> ex)
>>                Throw exc
>>            End Try
>>
>>            crViewer.ReportSource = myReport
>>
>>            Session("exportbestand") =
>> CType(myExportOptions.DestinationOptions,
>> CrystalDecisions.Shared.DiskFileDestinationOptions).DiskFileName
>>
>>        Catch err As Exception
>>            Response.Write("<BR>")
>>            Response.Write(err.Message.ToString)
>>        End Try
>>
>>
>>
>>
>>    End Sub
>>
>> #End Region
>>
>> #Region "Page Implementation"
>>
>>    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles MyBase.Load
>>        'Put user code to initialize the page here
>>    End Sub
>>
>>    Private Sub Page_Unload(ByVal sender As Object, ByVal e As
>> System.EventArgs) Handles MyBase.Unload
>>        Dim myExportFile As String = CType(Session.Item("exportbestand"),
>> String)
>>
>>        System.IO.File.Delete(myExportFile)
>>    End Sub
>>
>> #End Region
>>
>> #Region "Report Setup"
>>
>>    Private Sub PrepareReport(ByVal myReport As
>> CrystalDecisions.CrystalReports.Engine.ReportDocument)
>>
>>        Dim paramFields As ParameterFields
>>        Dim paramField As ParameterField
>>
>>        Const SessionExecption As String = "Unable to read session
>> objects."
>>
>>        Try
>>
>>            paramFields = New ParameterFields
>>            Try
>>                paramField = CreateParameter("FiliaalKeuze")
>>
>> paramField.CurrentValues.Add(CreateParameterDiscreteValue(GetSessionValue("DiscreteValue1")))
>>
>> paramField.CurrentValues.Add(CreateParameterDiscreteValue(GetSessionValue("DiscreteValue1")))
>>
>>            Catch ex As Exception
>>                Dim exc As System.ApplicationException
>>                exc = New System.ApplicationException(SessionExecption,
>> ex)
>>                Throw exc
>>            End Try
>>
>>            myReport.SetParameterValue("FiliaalKeuze", paramField)
>>
>>            Try
>>                'Todo wrap in try
>>                paramField = CreateParameter("Periode")
>>
>> paramField.CurrentValues.Add(CreateParameterRangeValue(GetSessionValue("BeginPeriode"),
>> GetSessionValue("EindPeriode")))
>>            Catch ex As Exception
>>                Dim exc As System.ApplicationException
>>                exc = New System.ApplicationException(SessionExecption,
>> ex)
>>                Throw exc
>>            End Try
>>
>>            myReport.SetParameterValue("Periode", paramField)
>>
>>        Catch ex As Exception
>>
>>            Dim exc As System.ApplicationException
>>            exc = New System.ApplicationException("Unable 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.ParameterFieldName = ParameterName
>>
>>        Return paramField
>>
>>    End Function
>>
>>    Private Function CreateParameterDiscreteValue(ByVal Value As Object)
>> As ParameterDiscreteValue
>>
>>        Dim paramDiscreteValue As ParameterDiscreteValue
>>        paramDiscreteValue = New ParameterDiscreteValue
>>        paramDiscreteValue = Value
>>
>>        Return paramDiscreteValue
>>
>>    End Function
>>
>>    Private Function CreateParameterRangeValue(ByVal StartRange As Object,
>> ByVal EndRange As Object) As ParameterRangeValue
>>        Dim paramRangeValue As ParameterRangeValue
>>
>>        paramRangeValue = New ParameterRangeValue
>>
>>        paramRangeValue.StartValue = StartRange
>>        paramRangeValue.EndValue = EndRange
>>
>>        Return paramRangeValue
>>    End Function
>>
>> #End Region
>>
>> #Region "Report Export"
>>
>>    Private Function GetExportOptions(ByVal UniqueFormat As
>> FileNameFormats, ByVal ExportOptions As
>> CrystalDecisions.Shared.ExportOptions) As
>> CrystalDecisions.Shared.ExportOptions
>>
>>        Dim myExportFile As String
>>        Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
>>        Dim myDiskFileDestinationOptions As
>> CrystalDecisions.Shared.DiskFileDestinationOptions
>>
>>        Try
>>
>>            Select Case UniqueFormat
>>                Case FileNameFormats.SessionID
>>                    myExportFile = Session.SessionID.ToString
>>                Case FileNameFormats.GUIDDashes
>>                    myExportFile = System.Guid.NewGuid.ToString("D")
>>                Case FileNameFormats.GUIDNoDashes
>>                    myExportFile = System.Guid.NewGuid.ToString("N")
>>            End Select
>>
>>            myExportFile = System.IO.Path.Combine(GetExportRoot,
>> String.Format("PDF_{0}.pdf", myExportFile))
>>
>>            myDiskFileDestinationOptions = New
>> CrystalDecisions.Shared.DiskFileDestinationOptions
>>            myDiskFileDestinationOptions.DiskFileName = myExportFile
>>
>>            myExportOptions = ExportOptions
>>
>>            With myExportOptions
>>                .DestinationOptions = myDiskFileDestinationOptions
>>                .ExportDestinationType = .ExportDestinationType.DiskFile
>>                .ExportFormatType = .ExportFormatType.PortableDocFormat
>>            End With
>>
>>        Catch ex As Exception
>>
>>            Dim exc As System.ApplicationException
>>            exc = New System.ApplicationException("Unable to prepare
>> export options.", ex)
>>            Throw exc
>>
>>        End Try
>>
>>        Return myExportOptions
>>
>>    End Function
>>
>>    Private Function GetExportRoot(ByVal FromApplication As Boolean) As
>> String
>>
>>        Dim strExportRoot As String
>>
>>        If FromApplication Then
>>            Try
>>                Application.Lock()
>>                strExportRoot = Application("ReportExportRoot")
>>            Catch ex As Exception
>>                Dim exc As ApplicationException
>>                exc = New ApplicationException("Unable to lock Web
>> Application for read.", ex)
>>                Throw exc
>>            Finally
>>                Application.UnLock()
>>            End Try
>>        Else
>>            strExportRoot = Session("ReportExportRoot")
>>        End If
>>
>>        Return strExportRoot
>>
>>    End Function
>>
>> #End Region
>>
>> #Region "Navigation Implementation"
>>
>>    Private Sub cmdPrint_Click(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles cmdPrint.Click
>>
>>        Response.ClearContent()
>>        Response.ClearHeaders()
>>        Response.ContentType = "application/pdf"
>>
>>        Dim myExportFile As String = CType(Session.Item("exportbestand"),
>> String)
>>
>>        Response.WriteFile(myExportFile)
>>        Response.Flush()
>>        Response.Close()
>>
>>        System.IO.File.Delete(myExportFile)
>>
>>    End Sub
>>
>>    Private Sub cmdEerste_Click(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles cmdEerste.Click
>>        crViewer.ShowFirstPage()
>>    End Sub
>>
>>    Private Sub cmdLaatste_Click(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles cmdLaatste.Click
>>        crViewer.ShowLastPage()
>>    End Sub
>>
>>    Private Sub cmdTerug_Click(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles cmdTerug.Click
>>        crViewer.ShowPreviousPage()
>>    End Sub
>>
>>    Private Sub cmdVerder_Click(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles cmdVerder.Click
>>        crViewer.ShowNextPage()
>>    End Sub
>>
>>  Private Sub drpZoom_SelectedIndexChanged(ByVal sender As Object, ByVal e
>> As System.EventArgs) Handles drpZoom.SelectedIndexChanged
>>        crViewer.Zoom(drpZoom.SelectedItem.Value)
>>    End Sub
>>
>> #End Region
>>
>>
>> End Class
>>
>>
>>
>>
>> "AMDRIT" <amd***@hotmail.com> wrote in message
>> news:OpMDndkNGHA.2064@TK2MSFTNGP09.phx.gbl...
>>> Ok, first the isue you were having with the "Blue lines" is:
>>>
>>> Private Function CreateParameterDiscreteValue(ByVal Value As Object) As
>>> ParameterDiscreteValue()
>>> -->        Retun type is expecting an array of ParameterDiscreteValue
>>>
>>> it should be
>>>
>>> Private Function CreateParameterDiscreteValue(ByVal Value As Object) As
>>> ParameterDiscreteValue
>>> -->        Retun type is expecting an single ParameterDiscreteValue
>>>
>>> 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.EventArgs) Handles MyBase.Init
>>>    'CODEGEN: This method call is required by the Web Form Designer
>>>    'Do not modify it using the code editor.
>>>    InitializeComponent()
>>>
>>>    Dim myReport As RapportAIRCOStoringen
>>>    Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
>>>
>>>    Try
>>>
>>>      Try
>>>        PrepareReport(myReport)
>>>      Catch ex As Exception
>>>        Dim exc As ApplicationException
>>>        exc = New ApplicationException("Unable to prepare report.", ex)
>>>        Throw exc
>>>      End Try
>>>
>>>      Try
>>>        'exporteren to pdf
>>>        myExportOptions = GetExportOptions(FileNameFormats.GUIDNoDashes,
>>> CType(myReport,
>>> CrystalDecisions.CrystalReports.Engine.ReportDocument).ExportOptions)
>>>        myReport.Export()
>>>
>>>      Catch ex As Exception
>>>        Dim exc As ApplicationException
>>>        exc = New ApplicationException("Unable to export report.", ex)
>>>        Throw exc
>>>      End Try
>>>
>>>      crViewer.ReportSource = myReport
>>>
>>>      Session("exportbestand") =
>>> CType(myExportOptions.DestinationOptions,
>>> CrystalDecisions.Shared.DiskFileDestinationOptions).DiskFileName
>>>
>>>    Catch err As Exception
>>>      Response.Write("<BR>")
>>>      Response.Write(err.Message.ToString)
>>>    End Try
>>>
>>>  End Sub
>>>
>>> #Region "Page Implementation"
>>>
>>>  Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
>>> System.EventArgs) Handles MyBase.Load
>>>    'Put user code to initialize the page here
>>>  End Sub
>>>
>>>  Private Sub Page_Unload(ByVal sender As Object, ByVal e As
>>> System.EventArgs) Handles MyBase.Unload
>>>    Dim myExportFile As String = CType(Session.Item("exportbestand"),
>>> String)
>>>
>>>    System.IO.File.Delete(myExportFile)
>>>  End Sub
>>>
>>> #End Region
>>>
>>> #Region "Report Setup"
>>>
>>>  Private Sub PrepareReport(ByVal myReport As
>>> CrystalDecisions.CrystalReports.Engine.ReportDocument)
>>>
>>>    Dim paramFields As ParameterFields
>>>    Dim paramField As ParameterField
>>>
>>>    Const SessionExecption As String = "Unable to read session objects."
>>>
>>>    Try
>>>
>>>      paramFields = New ParameterFields
>>>      Try
>>>        paramField = CreateParameter("FiliaalKeuze")
>>>
>>> paramField.CurrentValues.Add(CreateParameterDiscreteValue(GetSessionValue("DiscreteValue1")))
>>>
>>> paramField.CurrentValues.Add(CreateParameterDiscreteValue(GetSessionValue("DiscreteValue1")))
>>>      Catch ex As Exception
>>>        Dim exc As System.ApplicationException
>>>        exc = New System.ApplicationException(SessionExecption, ex)
>>>        Throw exc
>>>      End Try
>>>
>>>      myReport.SetParameterValue("FiliaalKeuze", paramField)
>>>
>>>      Try
>>>        'Todo wrap in try
>>>        paramField = CreateParameter("Periode")
>>>
>>> paramField.CurrentValues.Add(CreateParameterRangeValue(GetSessionValue("BeginPeriode"),
>>> GetSessionValue("EindPeriode")))
>>>      Catch ex As Exception
>>>        Dim exc As System.ApplicationException
>>>        exc = New System.ApplicationException(SessionExecption, ex)
>>>        Throw exc
>>>      End Try
>>>
>>>      myReport.SetParameterValue("Periode", paramField)
>>>
>>>    Catch ex As Exception
>>>
>>>      Dim exc As System.ApplicationException
>>>      exc = New System.ApplicationException("Unable 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.ParameterFieldName = ParameterName
>>>
>>>    Return paramField
>>>
>>>  End Function
>>>
>>>  Private Function CreateParameterDiscreteValue(ByVal Value As Object) As
>>> ParameterDiscreteValue()
>>>
>>>    Dim paramDiscreteValue As ParameterDiscreteValue
>>>    paramDiscreteValue = New ParameterDiscreteValue
>>>    paramDiscreteValue = Value
>>>
>>>    'Return paramDiscreteValue
>>>
>>>  End Function
>>>
>>>  Private Function CreateParameterRangeValue(ByVal StartRange As Object,
>>> ByVal EndRange As Object) As ParameterRangeValue
>>>    Dim paramRangeValue As ParameterRangeValue
>>>
>>>    paramRangeValue = New ParameterRangeValue
>>>
>>>    paramRangeValue.StartValue = StartRange
>>>    paramRangeValue.EndValue = EndRange
>>>
>>>    Return paramRangeValue
>>>  End Function
>>>
>>> #End Region
>>>
>>> #Region "Report Export"
>>>
>>>  Private Function GetExportOptions(ByVal UniqueFormat As
>>> FileNameFormats, ByVal ExportOptions As
>>> CrystalDecisions.Shared.ExportOptions) As
>>> CrystalDecisions.Shared.ExportOptions
>>>
>>>    Dim myExportFile As String
>>>    Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
>>>    Dim myDiskFileDestinationOptions As
>>> CrystalDecisions.Shared.DiskFileDestinationOptions
>>>
>>>    Try
>>>
>>>      Select Case UniqueFormat
>>>        Case FileNameFormats.SessionID
>>>          myExportFile = Session.SessionID.ToString
>>>        Case FileNameFormats.GUIDDashes
>>>          myExportFile = System.Guid.NewGuid.ToString("D")
>>>        Case FileNameFormats.GUIDNoDashes
>>>          myExportFile = System.Guid.NewGuid.ToString("N")
>>>      End Select
>>>
>>>      myExportFile = System.IO.Path.Combine(GetExportRoot,
>>> String.Format("PDF_{0}.pdf", myExportFile))
>>>
>>>      myDiskFileDestinationOptions = New
>>> CrystalDecisions.Shared.DiskFileDestinationOptions
>>>      myDiskFileDestinationOptions.DiskFileName = myExportFile
>>>
>>>      myExportOptions = ExportOptions
>>>
>>>      With myExportOptions
>>>        .DestinationOptions = myDiskFileDestinationOptions
>>>        .ExportDestinationType = .ExportDestinationType.DiskFile
>>>        .ExportFormatType = .ExportFormatType.PortableDocFormat
>>>      End With
>>>
>>>    Catch ex As Exception
>>>
>>>      Dim exc As System.ApplicationException
>>>      exc = New System.ApplicationException("Unable to prepare export
>>> options.", ex)
>>>      Throw exc
>>>
>>>    End Try
>>>
>>>    Return myExportOptions
>>>
>>>  End Function
>>>
>>>  Private Function GetExportRoot(ByVal FromApplication As Boolean) As
>>> String
>>>
>>>    Dim strExportRoot As String
>>>
>>>    If FromApplication Then
>>>      Try
>>>        Application.lock()
>>>        strExportRoot = Application("ReportExportRoot")
>>>      Catch ex As Exception
>>>        Dim exc As ApplicationException
>>>        exc = New ApplicationException("Unable to lock Web Application
>>> for read.", ex)
>>>        Throw exc
>>>      Finally
>>>        Application.unlock()
>>>      End Try
>>>    Else
>>>      strExportRoot = Session("ReportExportRoot")
>>>    End If
>>>
>>>    Return strExportRoot
>>>
>>>  End Function
>>>
>>> #End Region
>>>
>>> #Region "Navigation Implementation"
>>>
>>>  Private Sub cmdPrint_Click(ByVal sender As System.Object, ByVal e As
>>> System.EventArgs) Handles cmdPrint.Click
>>>
>>>    Response.ClearContent()
>>>    Response.ClearHeaders()
>>>    Response.ContentType = "application/pdf"
>>>
>>>    Dim myExportFile As String = CType(Session.Item("exportbestand"),
>>> String)
>>>
>>>    Response.WriteFile(myExportFile)
>>>    Response.Flush()
>>>    Response.Close()
>>>
>>>    System.IO.File.Delete(myExportFile)
>>>
>>>  End Sub
>>>
>>>  Private Sub cmdEerste_Click(ByVal sender As System.Object, ByVal e As
>>> System.EventArgs) Handles cmdEerste.Click
>>>    crViewer.ShowFirstPage()
>>>  End Sub
>>>
>>>  Private Sub cmdLaatste_Click(ByVal sender As System.Object, ByVal e As
>>> System.EventArgs) Handles cmdLaatste.Click
>>>    crViewer.ShowLastPage()
>>>  End Sub
>>>
>>>  Private Sub cmdTerug_Click(ByVal sender As System.Object, ByVal e As
>>> System.EventArgs) Handles cmdTerug.Click
>>>    crViewer.ShowPreviousPage()
>>>  End Sub
>>>
>>>  Private Sub cmdVerder_Click(ByVal sender As System.Object, ByVal e As
>>> System.EventArgs) Handles cmdVerder.Click
>>>    crViewer.ShowNextPage()
>>>  End Sub
>>>
>>>  Private Sub drpZoom_SelectedIndexChanged(ByVal sender As Object, ByVal
>>> e As System.EventArgs) Handles drpZoom.SelectedIndexChanged
>>>    crViewer.Zoom(drpZoom.SelectedItem.Value)
>>>  End Sub
>>>
>>> #End Region
>>>
>>>
>>> "Alison Givens" <i***@cross-it.nl> wrote in message
>>> news:%23RW%23bsjNGHA.2124@TK2MSFTNGP14.phx.gbl...
>>>>> Perhaps you could share your resulting code for comparison?  Did you
>>>>> see that I suggested the error in your code was
>>>>>
>>>>> myReport.SetParameterValue("FiliaalKeuze", 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 CrystalDecisions.CrystalReports.Engine
>>>> Imports CrystalDecisions.CrystalReports.Engine.ReportDocument
>>>> Imports CrystalDecisions.Shared
>>>> Imports System.IO
>>>>
>>>>
>>>> Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
>>>> System.EventArgs) Handles MyBase.Init
>>>>        'CODEGEN: This method call is required by the Web Form Designer
>>>>        'Do not modify it using the code editor.
>>>>        InitializeComponent()
>>>>
>>>>
>>>>
>>>>        Dim myReport As RapportAIRCOStoringen
>>>>        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.QueryString("BeginPeriode")
>>>>            EindPeriode = Request.QueryString("EindPeriode")
>>>>        Catch ex As Exception
>>>>            Dim exCustom As ApplicationException
>>>>            exCustom = New ApplicationException("Unable to parse Query
>>>> Paramaters.", ex)
>>>>            Throw exCustom
>>>>        End Try
>>>>
>>>>        'Todo wrap in try
>>>>        paramField = CreateParameter("FiliaalKeuze")
>>>>        paramField.CurrentValues.Add(CreateParameterDiscreteValue(2044))
>>>>        paramField.CurrentValues.Add(CreateParameterDiscreteValue(2344))
>>>>        myReport.SetParameterValue("FiliaalKeuze", paramField)
>>>>
>>>>
>>>>        'Todo wrap in try
>>>>        paramField = CreateParameter("Periode")
>>>>
>>>> paramField.CurrentValues.Add(CreateParameterRangeValue(BeginPeriode,
>>>> EindPeriode))
>>>>        myReport.SetParameterValue("Periode", paramField)
>>>>
>>>>
>>>>        crViewer.ReportSource = myReport
>>>>
>>>>
>>>>        'exporteren to pdf
>>>>        Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
>>>>        Dim myDiskFileDestinationOptions As
>>>> CrystalDecisions.Shared.DiskFileDestinationOptions
>>>>        Dim myExportFile As String
>>>>
>>>>
>>>>
>>>>        myExportFile = "\\192.168.2.106\syn2sql$\PDF_" &
>>>> Session.SessionID.ToString & ".pdf"
>>>>        myDiskFileDestinationOptions = New
>>>> CrystalDecisions.Shared.DiskFileDestinationOptions
>>>>        myDiskFileDestinationOptions.DiskFileName = myExportFile
>>>>        myExportOptions = myReport.ExportOptions
>>>>        With myExportOptions
>>>>            .DestinationOptions = myDiskFileDestinationOptions
>>>>            .ExportDestinationType = .ExportDestinationType.DiskFile
>>>>            .ExportFormatType = .ExportFormatType.PortableDocFormat
>>>>        End With
>>>>
>>>>        Try
>>>>            myReport.Export()
>>>>        Catch err As Exception
>>>>            Response.Write("<BR>")
>>>>            Response.Write(err.Message.ToString)
>>>>        End Try
>>>>
>>>>        Session("exportbestand") = myExportFile
>>>>    End Sub
>>>>
>>>> #End Region
>>>>
>>>>    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
>>>> System.EventArgs) 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.EventArgs) Handles cmdPrint.Click
>>>>        Response.ClearContent()
>>>>        Response.ClearHeaders()
>>>>        Response.ContentType = "application/pdf"
>>>>        Dim myExportFile As String =
>>>> CType(Session.Item("exportbestand"), String)
>>>>
>>>>        Response.WriteFile(myExportFile)
>>>>        Response.Flush()
>>>>        Response.Close()
>>>>
>>>>        System.IO.File.Delete(myExportFile)
>>>>    End Sub
>>>>
>>>>    Private Function CreateParameter(ByVal ParameterName As String) As
>>>> ParameterField()
>>>>        Dim paramField As ParameterField
>>>>
>>>>        paramField = New ParameterField
>>>>        paramField.ParameterFieldName = ParameterName
>>>>
>>>>        'Return paramField
>>>>
>>>>    End Function
>>>>
>>>>    Private Function CreateParameterDiscreteValue(ByVal Value As Object)
>>>> As ParameterDiscreteValue()
>>>>
>>>>        Dim paramDiscreteValue As ParameterDiscreteValue
>>>>        paramDiscreteValue = New ParameterDiscreteValue
>>>>        paramDiscreteValue = Value
>>>>
>>>>        'Return paramDiscreteValue
>>>>
>>>>    End Function
>>>>
>>>>    Private Function CreateParameterRangeValue(ByVal StartRange As
>>>> Object, ByVal EndRange As Object) As ParameterRangeValue
>>>>        Dim paramRangeValue As ParameterRangeValue
>>>>
>>>>        paramRangeValue = New ParameterRangeValue
>>>>
>>>>        paramRangeValue.StartValue = StartRange
>>>>        paramRangeValue.EndValue = EndRange
>>>>
>>>>        Return paramRangeValue
>>>>    End Function
>>>>
>>>>
>>>>    Private Sub cmdEerste_Click(ByVal sender As System.Object, ByVal e
>>>> As System.EventArgs) Handles cmdEerste.Click
>>>>        crViewer.ShowFirstPage()
>>>>    End Sub
>>>>
>>>>    Private Sub cmdLaatste_Click(ByVal sender As System.Object, ByVal e
>>>> As System.EventArgs) Handles cmdLaatste.Click
>>>>        crViewer.ShowLastPage()
>>>>    End Sub
>>>>
>>>>    Private Sub cmdTerug_Click(ByVal sender As System.Object, ByVal e As
>>>> System.EventArgs) Handles cmdTerug.Click
>>>>        crViewer.ShowPreviousPage()
>>>>    End Sub
>>>>
>>>>    Private Sub cmdVerder_Click(ByVal sender As System.Object, ByVal e
>>>> As System.EventArgs) Handles cmdVerder.Click
>>>>        crViewer.ShowNextPage()
>>>>    End Sub
>>>>
>>>>    Private Sub drpZoom_SelectedIndexChanged(ByVal sender As Object,
>>>> ByVal e As System.EventArgs) Handles drpZoom.SelectedIndexChanged
>>>>        crViewer.Zoom(drpZoom.SelectedItem.Value)
>>>>    End Sub
>>>>    Private Sub Page_Unload(ByVal sender As Object, ByVal e As
>>>> System.EventArgs) Handles MyBase.Unload
>>>>        Dim myExportFile As String =
>>>> CType(Session.Item("exportbestand"), String)
>>>>
>>>>        System.IO.File.Delete(myExportFile)
>>>>    End Sub
>>>> End Class
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>>
>>>>> "Alison Givens" <i***@cross-it.nl> wrote in message
>>>>> news:eeEqNEgNGHA.1288@TK2MSFTNGP09.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
>>>>>> CrystalDecisions.Shared.ParameterField' cannot be converted
>>>>>> to 'Crystal.Decisions.Shared.ParameterField'
>>>>>>
>>>>>> Return paramField
>>>>>> The text is:
>>>>>> Value of type 'CrystalDecisions.Shared.ParameterField' cannot be
>>>>>> converted
>>>>>> to '1 dimensional array of Crystal.Decisions.Shared.ParameterField'
>>>>>>
>>>>>> Same for
>>>>>> paramField = CreateParamater("Periode")
>>>>>> Return paramDiscreteValue
>>>>>>
>>>>>> Any idea what causes this?
>>>>>>
>>>>>> Alison
>>>>>>
>>>>>>
>>>>>> "AMDRIT" <amd***@hotmail.com> wrote in message
>>>>>> news:urCzE10MGHA.720@TK2MSFTNGP14.phx.gbl...
>>>>>>> Wow, you do all that for Crystal Reports?  What is
>>>>>>> RapportAIRCOStoringen?
>>>>>>>
>>>>>>>
>>>>>>> Here is all I do for CR
>>>>>>>
>>>>>>> Dim x As CrystalDecisions.CrystalReports.Engine.ReportDocument
>>>>>>>
>>>>>>> x.Load(sReportPath) 'Reports are not embedded resources
>>>>>>> x.SetParameterValue("Paramater1", Paramaters(1))      'Dynamic
>>>>>>> Paramaters
>>>>>>> x.SetParameterValue("Paramater2", Paramaters(2))
>>>>>>> x.SetDataSource(mydata) 'Strongly Typed Datasets
>>>>>>>
>>>>>>> Me.CrystalReportViewer1.ReportSource = x
>>>>>>> Me.CrystalReportViewer1.PrintReport()
>>>>>>>
>>>>>>>
>>>>>>> '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.SetParameterValue("FiliaalKeuze", discreteVal)
>>>>>>>
>>>>>>> Why are you setting the crView paramaters and the myReport
>>>>>>> paramaters?
>>>>>>>  -->crViewer.ParameterFieldInfo = paramFields
>>>>>>>  -->myReport.SetParameterValue("Periode", 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 RapportAIRCOStoringen
>>>>>>>    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.QueryString("BeginPeriode")
>>>>>>>      EindPeriode = Request.QueryString("EindPeriode")
>>>>>>>    Catch ex As Exception
>>>>>>>      Dim exCustom As ApplicationException
>>>>>>>      exCustom = New ApplicationException("Unable to parse Query
>>>>>>> Paramaters.", ex)
>>>>>>>      Throw exCustom
>>>>>>>    End Try
>>>>>>>
>>>>>>>    'Todo wrap in try
>>>>>>>    paramField = CreateParamater("FiliaalKeuze")
>>>>>>>    paramField.CurrentValues.Add(CreateParameterDiscreteValue(2044))
>>>>>>>    paramField.CurrentValues.Add(CreateParameterDiscreteValue(2344))
>>>>>>>    myReport.SetParameterValue("FiliaalKeuze", paramField)
>>>>>>>    'paramFields.Add(paramField) --> Not needed
>>>>>>>
>>>>>>>    'Todo wrap in try
>>>>>>>    paramField = CreateParamater("Periode")
>>>>>>>
>>>>>>> paramField.CurrentValues.Add(CreateParameterRangeValue(BeginPeriode,
>>>>>>> EindPeriode))
>>>>>>>    myReport.SetParameterValue("Periode", paramField)
>>>>>>>    'paramFields.Add(paramField)--> Not needed
>>>>>>>
>>>>>>>    'Todo wrap in try, i don't think you need this
>>>>>>>    'myReport.SetParameterValue("Periode", rangeVal)
>>>>>>>    'myReport.SetParameterValue("FiliaalKeuze", discreteVal)
>>>>>>>
>>>>>>>    'Todo, determine if we need this step; I don't think you do
>>>>>>>    'crViewer.ParameterFieldInfo = paramFields
>>>>>>>
>>>>>>>    crViewer.ReportSource = myReport
>>>>>>>
>>>>>>>  End Sub
>>>>>>>
>>>>>>>  Private Function CreateParamater(ByVal ParamaterName As String) As
>>>>>>> ParameterField
>>>>>>>    Dim paramField As ParameterField
>>>>>>>
>>>>>>>    paramField = New ParameterField
>>>>>>>    paramField.ParameterFieldName = ParamaterName
>>>>>>>
>>>>>>>    Return paramField
>>>>>>>
>>>>>>>  End Function
>>>>>>>
>>>>>>>  Private Function CreateParameterDiscreteValue(ByVal Value As
>>>>>>> Object) As ParameterDiscreteValue
>>>>>>>
>>>>>>>    Dim paramDiscreteValue As ParameterDiscreteValue
>>>>>>>    paramDiscreteValue = New ParameterDiscreteValue
>>>>>>>    paramDiscreteValue = Value
>>>>>>>
>>>>>>>    Return paramDiscreteValue
>>>>>>>
>>>>>>>  End Function
>>>>>>>
>>>>>>>  Private Function CreateParameterRangeValue(ByVal StartRange As
>>>>>>> Object, ByVal EndRange As Object) As ParameterRangeValue
>>>>>>>    Dim paramRangeValue As ParameterRangeValue
>>>>>>>
>>>>>>>    paramRangeValue = New ParameterRangeValue
>>>>>>>
>>>>>>>    paramRangeValue.StartValue = StartRange
>>>>>>>    paramRangeValue.EndValue = EndRange
>>>>>>>
>>>>>>>    Return paramRangeValue
>>>>>>>  End Function
>>>>>>>
>>>>>>> "Alison Givens" <i***@cross-it.nl> wrote in message
>>>>>>> news:eW4b66tMGHA.668@TK2MSFTNGP11.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.QueryString("BeginPeriode")
>>>>>>>> EindPeriode = Request.QueryString("EindPeriode")
>>>>>>>>
>>>>>>>> Dim myReport As New RapportAIRCOStoringen
>>>>>>>>
>>>>>>>> Dim paramFields As New ParameterFields
>>>>>>>> Dim paramField As New ParameterField
>>>>>>>> Dim discreteVal As New ParameterDiscreteValue
>>>>>>>> Dim rangeVal As New ParameterRangeValue
>>>>>>>>
>>>>>>>> paramField.ParameterFieldName = "FiliaalKeuze"
>>>>>>>> discreteVal.Value = "2044"
>>>>>>>> paramField.CurrentValues.Add(discreteVal)
>>>>>>>>
>>>>>>>> discreteVal = New ParameterDiscreteValue
>>>>>>>> discreteVal.Value = "2344"
>>>>>>>> paramField.CurrentValues.Add(discreteVal)
>>>>>>>>
>>>>>>>> paramFields.Add(paramField)
>>>>>>>>
>>>>>>>> paramField = New ParameterField
>>>>>>>>
>>>>>>>> paramField.ParameterFieldName = "Periode"
>>>>>>>>
>>>>>>>> rangeVal.StartValue = BeginPeriode
>>>>>>>> rangeVal.EndValue = EindPeriode
>>>>>>>> paramField.CurrentValues.Add(rangeVal)
>>>>>>>>
>>>>>>>> paramFields.Add(paramField)
>>>>>>>>
>>>>>>>> crViewer.ParameterFieldInfo = paramFields
>>>>>>>> myReport.SetParameterValue("Periode", rangeVal)
>>>>>>>> myReport.SetParameterValue("FiliaalKeuze", discreteVal)
>>>>>>>> crViewer.ReportSource = myReport
>>>>>>>>
>>>>>>>> As you can see I use myReport.SetParameterValue 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
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
Author
22 Feb 2006 3:45 PM
AMDRIT
Perhaps web.config is case sensitive.

<configuration>
  <appSettings>
    <add key="ReportExportRoot" value="\\192.168.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(KeyName)
catch ex as exception
  dim exc as applicationexception
  exc = new applicationexception(string.format("Unable to read value from
session:{0}",KeyName),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/EventDetails.aspx?CMTYSvcSource=MSCOMMedia&Params=%7eCMTYDataSvcParams%5e%7earg+Name%3d%22ID%22+Value%3d%221032280467%22%2f%5e%7earg+Name%3d%22ProviderID%22+Value%3d%22A6B43178-497C-4225-BA42-DF595171F04C%22%2f%5e%7earg+Name%3d%22lang%22+Value%3d%22en%22%2f%5e%7earg+Name%3d%22cr%22+Value%3d%22US%22%2f%5e%7esParams%5e%7e%2fsParams%5e%7e%2fCMTYDataSvcParams%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.

Show quoteHide quote
"Alison Givens" <i***@cross-it.nl> wrote in message
news:uV136d4NGHA.516@TK2MSFTNGP15.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:  <configuration>
> Line 3:      <appSettings>
> Line 4:    <Add key="ReportExportRoot" Value
> ="\\192.168.2.106\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(KeyName)
> 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" <amd***@hotmail.com> wrote in message
> news:OYjEf9vNGHA.532@TK2MSFTNGP15.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(KeyName)
>>
>> 2.   Correct the line
>>        myExportFile = System.IO.Path.Combine(GetExportRoot,
>> String.Format("PDF_{0}.pdf", myExportFile))
>>       to
>>         myExportFile = System.IO.Path.Combine(GetExportRoot(false),
>> String.Format("PDF_{0}.pdf", myExportFile))
>>       or
>>         myExportFile = System.IO.Path.Combine(GetExportRoot(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 ReportExportRoot in
>> Application_OnStart, 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="ReportExportRoot" Value = "\\192.168.2.106\syn2sql$\PDF_" />
>> for more information on appsettings see:
>> ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/cpgenref/html/gngrfappsettingselement.htm
>>
>> in your application's global.asax on Application_OnStart
>> ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/vbcon/html/vbconPageApplicationContext.htm
>> ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/cpguide/html/cpcontheglobalasaxfile.htm
>>
>> sub application_onstart()
>>  Dim ReportExportRoot as string
>>  ReportExportRoot =
>> System.Configuration.ConfigurationSettings.AppSettings("ReportExportRoot")
>>  Application.Lock
>>    Application("ReportExportRoot") = ReportExportRoot
>>  Application.Unlock
>> end sub
>>
>> in you application's global.asax on Session_OnStart
>> sub Session_Onstart()
>>  Dim ReportExportRoot as string
>>  Application.Lock
>>    ReportExportRoot = ctype(Application("ReportExportRoot"),string)
>>  Application.Unlock
>>  Session.item("ReportExportRoot") = ReportExportRoot
>> end sub
>>
>> "Alison Givens" <i***@cross-it.nl> wrote in message
>> news:OTYvuJsNGHA.3164@TK2MSFTNGP11.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(GetExportRoot,
>>> String.Format("PDF_{0}.pdf", myExportFile))
>>> Says:Argument not specified for parameter 'FromApplication' of
>>> 'Private Function GetExportRoot(FromApplication 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.EventArgs) Handles MyBase.Init
>>>        'CODEGEN: This method call is required by the Web Form Designer
>>>        'Do not modify it using the code editor.
>>>        InitializeComponent()
>>>        Dim myReport As RapportAIRCOStoringen
>>>        Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
>>>
>>>        Try
>>>
>>>            Try
>>>                PrepareReport(myReport)
>>>            Catch ex As Exception
>>>                Dim exc As ApplicationException
>>>                exc = New ApplicationException("Unable to prepare
>>> report.", ex)
>>>                Throw exc
>>>            End Try
>>>
>>>            Try
>>>                'exporteren to pdf
>>>                myExportOptions =
>>> GetExportOptions(FileNameFormats.GUIDNoDashes, CType(myReport,
>>> CrystalDecisions.CrystalReports.Engine.ReportDocument).ExportOptions)
>>>                myReport.Export()
>>>
>>>            Catch ex As Exception
>>>                Dim exc As ApplicationException
>>>                exc = New ApplicationException("Unable to export
>>> report.", ex)
>>>                Throw exc
>>>            End Try
>>>
>>>            crViewer.ReportSource = myReport
>>>
>>>            Session("exportbestand") =
>>> CType(myExportOptions.DestinationOptions,
>>> CrystalDecisions.Shared.DiskFileDestinationOptions).DiskFileName
>>>
>>>        Catch err As Exception
>>>            Response.Write("<BR>")
>>>            Response.Write(err.Message.ToString)
>>>        End Try
>>>
>>>
>>>
>>>
>>>    End Sub
>>>
>>> #End Region
>>>
>>> #Region "Page Implementation"
>>>
>>>    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
>>> System.EventArgs) Handles MyBase.Load
>>>        'Put user code to initialize the page here
>>>    End Sub
>>>
>>>    Private Sub Page_Unload(ByVal sender As Object, ByVal e As
>>> System.EventArgs) Handles MyBase.Unload
>>>        Dim myExportFile As String = CType(Session.Item("exportbestand"),
>>> String)
>>>
>>>        System.IO.File.Delete(myExportFile)
>>>    End Sub
>>>
>>> #End Region
>>>
>>> #Region "Report Setup"
>>>
>>>    Private Sub PrepareReport(ByVal myReport As
>>> CrystalDecisions.CrystalReports.Engine.ReportDocument)
>>>
>>>        Dim paramFields As ParameterFields
>>>        Dim paramField As ParameterField
>>>
>>>        Const SessionExecption As String = "Unable to read session
>>> objects."
>>>
>>>        Try
>>>
>>>            paramFields = New ParameterFields
>>>            Try
>>>                paramField = CreateParameter("FiliaalKeuze")
>>>
>>> paramField.CurrentValues.Add(CreateParameterDiscreteValue(GetSessionValue("DiscreteValue1")))
>>>
>>> paramField.CurrentValues.Add(CreateParameterDiscreteValue(GetSessionValue("DiscreteValue1")))
>>>
>>>            Catch ex As Exception
>>>                Dim exc As System.ApplicationException
>>>                exc = New System.ApplicationException(SessionExecption,
>>> ex)
>>>                Throw exc
>>>            End Try
>>>
>>>            myReport.SetParameterValue("FiliaalKeuze", paramField)
>>>
>>>            Try
>>>                'Todo wrap in try
>>>                paramField = CreateParameter("Periode")
>>>
>>> paramField.CurrentValues.Add(CreateParameterRangeValue(GetSessionValue("BeginPeriode"),
>>> GetSessionValue("EindPeriode")))
>>>            Catch ex As Exception
>>>                Dim exc As System.ApplicationException
>>>                exc = New System.ApplicationException(SessionExecption,
>>> ex)
>>>                Throw exc
>>>            End Try
>>>
>>>            myReport.SetParameterValue("Periode", paramField)
>>>
>>>        Catch ex As Exception
>>>
>>>            Dim exc As System.ApplicationException
>>>            exc = New System.ApplicationException("Unable 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.ParameterFieldName = ParameterName
>>>
>>>        Return paramField
>>>
>>>    End Function
>>>
>>>    Private Function CreateParameterDiscreteValue(ByVal Value As Object)
>>> As ParameterDiscreteValue
>>>
>>>        Dim paramDiscreteValue As ParameterDiscreteValue
>>>        paramDiscreteValue = New ParameterDiscreteValue
>>>        paramDiscreteValue = Value
>>>
>>>        Return paramDiscreteValue
>>>
>>>    End Function
>>>
>>>    Private Function CreateParameterRangeValue(ByVal StartRange As
>>> Object, ByVal EndRange As Object) As ParameterRangeValue
>>>        Dim paramRangeValue As ParameterRangeValue
>>>
>>>        paramRangeValue = New ParameterRangeValue
>>>
>>>        paramRangeValue.StartValue = StartRange
>>>        paramRangeValue.EndValue = EndRange
>>>
>>>        Return paramRangeValue
>>>    End Function
>>>
>>> #End Region
>>>
>>> #Region "Report Export"
>>>
>>>    Private Function GetExportOptions(ByVal UniqueFormat As
>>> FileNameFormats, ByVal ExportOptions As
>>> CrystalDecisions.Shared.ExportOptions) As
>>> CrystalDecisions.Shared.ExportOptions
>>>
>>>        Dim myExportFile As String
>>>        Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
>>>        Dim myDiskFileDestinationOptions As
>>> CrystalDecisions.Shared.DiskFileDestinationOptions
>>>
>>>        Try
>>>
>>>            Select Case UniqueFormat
>>>                Case FileNameFormats.SessionID
>>>                    myExportFile = Session.SessionID.ToString
>>>                Case FileNameFormats.GUIDDashes
>>>                    myExportFile = System.Guid.NewGuid.ToString("D")
>>>                Case FileNameFormats.GUIDNoDashes
>>>                    myExportFile = System.Guid.NewGuid.ToString("N")
>>>            End Select
>>>
>>>            myExportFile = System.IO.Path.Combine(GetExportRoot,
>>> String.Format("PDF_{0}.pdf", myExportFile))
>>>
>>>            myDiskFileDestinationOptions = New
>>> CrystalDecisions.Shared.DiskFileDestinationOptions
>>>            myDiskFileDestinationOptions.DiskFileName = myExportFile
>>>
>>>            myExportOptions = ExportOptions
>>>
>>>            With myExportOptions
>>>                .DestinationOptions = myDiskFileDestinationOptions
>>>                .ExportDestinationType = .ExportDestinationType.DiskFile
>>>                .ExportFormatType = .ExportFormatType.PortableDocFormat
>>>            End With
>>>
>>>        Catch ex As Exception
>>>
>>>            Dim exc As System.ApplicationException
>>>            exc = New System.ApplicationException("Unable to prepare
>>> export options.", ex)
>>>            Throw exc
>>>
>>>        End Try
>>>
>>>        Return myExportOptions
>>>
>>>    End Function
>>>
>>>    Private Function GetExportRoot(ByVal FromApplication As Boolean) As
>>> String
>>>
>>>        Dim strExportRoot As String
>>>
>>>        If FromApplication Then
>>>            Try
>>>                Application.Lock()
>>>                strExportRoot = Application("ReportExportRoot")
>>>            Catch ex As Exception
>>>                Dim exc As ApplicationException
>>>                exc = New ApplicationException("Unable to lock Web
>>> Application for read.", ex)
>>>                Throw exc
>>>            Finally
>>>                Application.UnLock()
>>>            End Try
>>>        Else
>>>            strExportRoot = Session("ReportExportRoot")
>>>        End If
>>>
>>>        Return strExportRoot
>>>
>>>    End Function
>>>
>>> #End Region
>>>
>>> #Region "Navigation Implementation"
>>>
>>>    Private Sub cmdPrint_Click(ByVal sender As System.Object, ByVal e As
>>> System.EventArgs) Handles cmdPrint.Click
>>>
>>>        Response.ClearContent()
>>>        Response.ClearHeaders()
>>>        Response.ContentType = "application/pdf"
>>>
>>>        Dim myExportFile As String = CType(Session.Item("exportbestand"),
>>> String)
>>>
>>>        Response.WriteFile(myExportFile)
>>>        Response.Flush()
>>>        Response.Close()
>>>
>>>        System.IO.File.Delete(myExportFile)
>>>
>>>    End Sub
>>>
>>>    Private Sub cmdEerste_Click(ByVal sender As System.Object, ByVal e As
>>> System.EventArgs) Handles cmdEerste.Click
>>>        crViewer.ShowFirstPage()
>>>    End Sub
>>>
>>>    Private Sub cmdLaatste_Click(ByVal sender As System.Object, ByVal e
>>> As System.EventArgs) Handles cmdLaatste.Click
>>>        crViewer.ShowLastPage()
>>>    End Sub
>>>
>>>    Private Sub cmdTerug_Click(ByVal sender As System.Object, ByVal e As
>>> System.EventArgs) Handles cmdTerug.Click
>>>        crViewer.ShowPreviousPage()
>>>    End Sub
>>>
>>>    Private Sub cmdVerder_Click(ByVal sender As System.Object, ByVal e As
>>> System.EventArgs) Handles cmdVerder.Click
>>>        crViewer.ShowNextPage()
>>>    End Sub
>>>
>>>  Private Sub drpZoom_SelectedIndexChanged(ByVal sender As Object, ByVal
>>> e
>>> As System.EventArgs) Handles drpZoom.SelectedIndexChanged
>>>        crViewer.Zoom(drpZoom.SelectedItem.Value)
>>>    End Sub
>>>
>>> #End Region
>>>
>>>
>>> End Class
>>>
>>>
>>>
>>>
>>> "AMDRIT" <amd***@hotmail.com> wrote in message
>>> news:OpMDndkNGHA.2064@TK2MSFTNGP09.phx.gbl...
>>>> Ok, first the isue you were having with the "Blue lines" is:
>>>>
>>>> Private Function CreateParameterDiscreteValue(ByVal Value As Object) As
>>>> ParameterDiscreteValue()
>>>> -->        Retun type is expecting an array of ParameterDiscreteValue
>>>>
>>>> it should be
>>>>
>>>> Private Function CreateParameterDiscreteValue(ByVal Value As Object) As
>>>> ParameterDiscreteValue
>>>> -->        Retun type is expecting an single ParameterDiscreteValue
>>>>
>>>> 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.EventArgs) Handles MyBase.Init
>>>>    'CODEGEN: This method call is required by the Web Form Designer
>>>>    'Do not modify it using the code editor.
>>>>    InitializeComponent()
>>>>
>>>>    Dim myReport As RapportAIRCOStoringen
>>>>    Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
>>>>
>>>>    Try
>>>>
>>>>      Try
>>>>        PrepareReport(myReport)
>>>>      Catch ex As Exception
>>>>        Dim exc As ApplicationException
>>>>        exc = New ApplicationException("Unable to prepare report.", ex)
>>>>        Throw exc
>>>>      End Try
>>>>
>>>>      Try
>>>>        'exporteren to pdf
>>>>        myExportOptions = GetExportOptions(FileNameFormats.GUIDNoDashes,
>>>> CType(myReport,
>>>> CrystalDecisions.CrystalReports.Engine.ReportDocument).ExportOptions)
>>>>        myReport.Export()
>>>>
>>>>      Catch ex As Exception
>>>>        Dim exc As ApplicationException
>>>>        exc = New ApplicationException("Unable to export report.", ex)
>>>>        Throw exc
>>>>      End Try
>>>>
>>>>      crViewer.ReportSource = myReport
>>>>
>>>>      Session("exportbestand") =
>>>> CType(myExportOptions.DestinationOptions,
>>>> CrystalDecisions.Shared.DiskFileDestinationOptions).DiskFileName
>>>>
>>>>    Catch err As Exception
>>>>      Response.Write("<BR>")
>>>>      Response.Write(err.Message.ToString)
>>>>    End Try
>>>>
>>>>  End Sub
>>>>
>>>> #Region "Page Implementation"
>>>>
>>>>  Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
>>>> System.EventArgs) Handles MyBase.Load
>>>>    'Put user code to initialize the page here
>>>>  End Sub
>>>>
>>>>  Private Sub Page_Unload(ByVal sender As Object, ByVal e As
>>>> System.EventArgs) Handles MyBase.Unload
>>>>    Dim myExportFile As String = CType(Session.Item("exportbestand"),
>>>> String)
>>>>
>>>>    System.IO.File.Delete(myExportFile)
>>>>  End Sub
>>>>
>>>> #End Region
>>>>
>>>> #Region "Report Setup"
>>>>
>>>>  Private Sub PrepareReport(ByVal myReport As
>>>> CrystalDecisions.CrystalReports.Engine.ReportDocument)
>>>>
>>>>    Dim paramFields As ParameterFields
>>>>    Dim paramField As ParameterField
>>>>
>>>>    Const SessionExecption As String = "Unable to read session objects."
>>>>
>>>>    Try
>>>>
>>>>      paramFields = New ParameterFields
>>>>      Try
>>>>        paramField = CreateParameter("FiliaalKeuze")
>>>>
>>>> paramField.CurrentValues.Add(CreateParameterDiscreteValue(GetSessionValue("DiscreteValue1")))
>>>>
>>>> paramField.CurrentValues.Add(CreateParameterDiscreteValue(GetSessionValue("DiscreteValue1")))
>>>>      Catch ex As Exception
>>>>        Dim exc As System.ApplicationException
>>>>        exc = New System.ApplicationException(SessionExecption, ex)
>>>>        Throw exc
>>>>      End Try
>>>>
>>>>      myReport.SetParameterValue("FiliaalKeuze", paramField)
>>>>
>>>>      Try
>>>>        'Todo wrap in try
>>>>        paramField = CreateParameter("Periode")
>>>>
>>>> paramField.CurrentValues.Add(CreateParameterRangeValue(GetSessionValue("BeginPeriode"),
>>>> GetSessionValue("EindPeriode")))
>>>>      Catch ex As Exception
>>>>        Dim exc As System.ApplicationException
>>>>        exc = New System.ApplicationException(SessionExecption, ex)
>>>>        Throw exc
>>>>      End Try
>>>>
>>>>      myReport.SetParameterValue("Periode", paramField)
>>>>
>>>>    Catch ex As Exception
>>>>
>>>>      Dim exc As System.ApplicationException
>>>>      exc = New System.ApplicationException("Unable 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.ParameterFieldName = ParameterName
>>>>
>>>>    Return paramField
>>>>
>>>>  End Function
>>>>
>>>>  Private Function CreateParameterDiscreteValue(ByVal Value As Object)
>>>> As ParameterDiscreteValue()
>>>>
>>>>    Dim paramDiscreteValue As ParameterDiscreteValue
>>>>    paramDiscreteValue = New ParameterDiscreteValue
>>>>    paramDiscreteValue = Value
>>>>
>>>>    'Return paramDiscreteValue
>>>>
>>>>  End Function
>>>>
>>>>  Private Function CreateParameterRangeValue(ByVal StartRange As Object,
>>>> ByVal EndRange As Object) As ParameterRangeValue
>>>>    Dim paramRangeValue As ParameterRangeValue
>>>>
>>>>    paramRangeValue = New ParameterRangeValue
>>>>
>>>>    paramRangeValue.StartValue = StartRange
>>>>    paramRangeValue.EndValue = EndRange
>>>>
>>>>    Return paramRangeValue
>>>>  End Function
>>>>
>>>> #End Region
>>>>
>>>> #Region "Report Export"
>>>>
>>>>  Private Function GetExportOptions(ByVal UniqueFormat As
>>>> FileNameFormats, ByVal ExportOptions As
>>>> CrystalDecisions.Shared.ExportOptions) As
>>>> CrystalDecisions.Shared.ExportOptions
>>>>
>>>>    Dim myExportFile As String
>>>>    Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
>>>>    Dim myDiskFileDestinationOptions As
>>>> CrystalDecisions.Shared.DiskFileDestinationOptions
>>>>
>>>>    Try
>>>>
>>>>      Select Case UniqueFormat
>>>>        Case FileNameFormats.SessionID
>>>>          myExportFile = Session.SessionID.ToString
>>>>        Case FileNameFormats.GUIDDashes
>>>>          myExportFile = System.Guid.NewGuid.ToString("D")
>>>>        Case FileNameFormats.GUIDNoDashes
>>>>          myExportFile = System.Guid.NewGuid.ToString("N")
>>>>      End Select
>>>>
>>>>      myExportFile = System.IO.Path.Combine(GetExportRoot,
>>>> String.Format("PDF_{0}.pdf", myExportFile))
>>>>
>>>>      myDiskFileDestinationOptions = New
>>>> CrystalDecisions.Shared.DiskFileDestinationOptions
>>>>      myDiskFileDestinationOptions.DiskFileName = myExportFile
>>>>
>>>>      myExportOptions = ExportOptions
>>>>
>>>>      With myExportOptions
>>>>        .DestinationOptions = myDiskFileDestinationOptions
>>>>        .ExportDestinationType = .ExportDestinationType.DiskFile
>>>>        .ExportFormatType = .ExportFormatType.PortableDocFormat
>>>>      End With
>>>>
>>>>    Catch ex As Exception
>>>>
>>>>      Dim exc As System.ApplicationException
>>>>      exc = New System.ApplicationException("Unable to prepare export
>>>> options.", ex)
>>>>      Throw exc
>>>>
>>>>    End Try
>>>>
>>>>    Return myExportOptions
>>>>
>>>>  End Function
>>>>
>>>>  Private Function GetExportRoot(ByVal FromApplication As Boolean) As
>>>> String
>>>>
>>>>    Dim strExportRoot As String
>>>>
>>>>    If FromApplication Then
>>>>      Try
>>>>        Application.lock()
>>>>        strExportRoot = Application("ReportExportRoot")
>>>>      Catch ex As Exception
>>>>        Dim exc As ApplicationException
>>>>        exc = New ApplicationException("Unable to lock Web Application
>>>> for read.", ex)
>>>>        Throw exc
>>>>      Finally
>>>>        Application.unlock()
>>>>      End Try
>>>>    Else
>>>>      strExportRoot = Session("ReportExportRoot")
>>>>    End If
>>>>
>>>>    Return strExportRoot
>>>>
>>>>  End Function
>>>>
>>>> #End Region
>>>>
>>>> #Region "Navigation Implementation"
>>>>
>>>>  Private Sub cmdPrint_Click(ByVal sender As System.Object, ByVal e As
>>>> System.EventArgs) Handles cmdPrint.Click
>>>>
>>>>    Response.ClearContent()
>>>>    Response.ClearHeaders()
>>>>    Response.ContentType = "application/pdf"
>>>>
>>>>    Dim myExportFile As String = CType(Session.Item("exportbestand"),
>>>> String)
>>>>
>>>>    Response.WriteFile(myExportFile)
>>>>    Response.Flush()
>>>>    Response.Close()
>>>>
>>>>    System.IO.File.Delete(myExportFile)
>>>>
>>>>  End Sub
>>>>
>>>>  Private Sub cmdEerste_Click(ByVal sender As System.Object, ByVal e As
>>>> System.EventArgs) Handles cmdEerste.Click
>>>>    crViewer.ShowFirstPage()
>>>>  End Sub
>>>>
>>>>  Private Sub cmdLaatste_Click(ByVal sender As System.Object, ByVal e As
>>>> System.EventArgs) Handles cmdLaatste.Click
>>>>    crViewer.ShowLastPage()
>>>>  End Sub
>>>>
>>>>  Private Sub cmdTerug_Click(ByVal sender As System.Object, ByVal e As
>>>> System.EventArgs) Handles cmdTerug.Click
>>>>    crViewer.ShowPreviousPage()
>>>>  End Sub
>>>>
>>>>  Private Sub cmdVerder_Click(ByVal sender As System.Object, ByVal e As
>>>> System.EventArgs) Handles cmdVerder.Click
>>>>    crViewer.ShowNextPage()
>>>>  End Sub
>>>>
>>>>  Private Sub drpZoom_SelectedIndexChanged(ByVal sender As Object, ByVal
>>>> e As System.EventArgs) Handles drpZoom.SelectedIndexChanged
>>>>    crViewer.Zoom(drpZoom.SelectedItem.Value)
>>>>  End Sub
>>>>
>>>> #End Region
>>>>
>>>>
>>>> "Alison Givens" <i***@cross-it.nl> wrote in message
>>>> news:%23RW%23bsjNGHA.2124@TK2MSFTNGP14.phx.gbl...
>>>>>> Perhaps you could share your resulting code for comparison?  Did you
>>>>>> see that I suggested the error in your code was
>>>>>>
>>>>>> myReport.SetParameterValue("FiliaalKeuze", 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 CrystalDecisions.CrystalReports.Engine
>>>>> Imports CrystalDecisions.CrystalReports.Engine.ReportDocument
>>>>> Imports CrystalDecisions.Shared
>>>>> Imports System.IO
>>>>>
>>>>>
>>>>> Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
>>>>> System.EventArgs) Handles MyBase.Init
>>>>>        'CODEGEN: This method call is required by the Web Form Designer
>>>>>        'Do not modify it using the code editor.
>>>>>        InitializeComponent()
>>>>>
>>>>>
>>>>>
>>>>>        Dim myReport As RapportAIRCOStoringen
>>>>>        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.QueryString("BeginPeriode")
>>>>>            EindPeriode = Request.QueryString("EindPeriode")
>>>>>        Catch ex As Exception
>>>>>            Dim exCustom As ApplicationException
>>>>>            exCustom = New ApplicationException("Unable to parse Query
>>>>> Paramaters.", ex)
>>>>>            Throw exCustom
>>>>>        End Try
>>>>>
>>>>>        'Todo wrap in try
>>>>>        paramField = CreateParameter("FiliaalKeuze")
>>>>>
>>>>> paramField.CurrentValues.Add(CreateParameterDiscreteValue(2044))
>>>>>
>>>>> paramField.CurrentValues.Add(CreateParameterDiscreteValue(2344))
>>>>>        myReport.SetParameterValue("FiliaalKeuze", paramField)
>>>>>
>>>>>
>>>>>        'Todo wrap in try
>>>>>        paramField = CreateParameter("Periode")
>>>>>
>>>>> paramField.CurrentValues.Add(CreateParameterRangeValue(BeginPeriode,
>>>>> EindPeriode))
>>>>>        myReport.SetParameterValue("Periode", paramField)
>>>>>
>>>>>
>>>>>        crViewer.ReportSource = myReport
>>>>>
>>>>>
>>>>>        'exporteren to pdf
>>>>>        Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
>>>>>        Dim myDiskFileDestinationOptions As
>>>>> CrystalDecisions.Shared.DiskFileDestinationOptions
>>>>>        Dim myExportFile As String
>>>>>
>>>>>
>>>>>
>>>>>        myExportFile = "\\192.168.2.106\syn2sql$\PDF_" &
>>>>> Session.SessionID.ToString & ".pdf"
>>>>>        myDiskFileDestinationOptions = New
>>>>> CrystalDecisions.Shared.DiskFileDestinationOptions
>>>>>        myDiskFileDestinationOptions.DiskFileName = myExportFile
>>>>>        myExportOptions = myReport.ExportOptions
>>>>>        With myExportOptions
>>>>>            .DestinationOptions = myDiskFileDestinationOptions
>>>>>            .ExportDestinationType = .ExportDestinationType.DiskFile
>>>>>            .ExportFormatType = .ExportFormatType.PortableDocFormat
>>>>>        End With
>>>>>
>>>>>        Try
>>>>>            myReport.Export()
>>>>>        Catch err As Exception
>>>>>            Response.Write("<BR>")
>>>>>            Response.Write(err.Message.ToString)
>>>>>        End Try
>>>>>
>>>>>        Session("exportbestand") = myExportFile
>>>>>    End Sub
>>>>>
>>>>> #End Region
>>>>>
>>>>>    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
>>>>> System.EventArgs) 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.EventArgs) Handles cmdPrint.Click
>>>>>        Response.ClearContent()
>>>>>        Response.ClearHeaders()
>>>>>        Response.ContentType = "application/pdf"
>>>>>        Dim myExportFile As String =
>>>>> CType(Session.Item("exportbestand"), String)
>>>>>
>>>>>        Response.WriteFile(myExportFile)
>>>>>        Response.Flush()
>>>>>        Response.Close()
>>>>>
>>>>>        System.IO.File.Delete(myExportFile)
>>>>>    End Sub
>>>>>
>>>>>    Private Function CreateParameter(ByVal ParameterName As String) As
>>>>> ParameterField()
>>>>>        Dim paramField As ParameterField
>>>>>
>>>>>        paramField = New ParameterField
>>>>>        paramField.ParameterFieldName = ParameterName
>>>>>
>>>>>        'Return paramField
>>>>>
>>>>>    End Function
>>>>>
>>>>>    Private Function CreateParameterDiscreteValue(ByVal Value As
>>>>> Object) As ParameterDiscreteValue()
>>>>>
>>>>>        Dim paramDiscreteValue As ParameterDiscreteValue
>>>>>        paramDiscreteValue = New ParameterDiscreteValue
>>>>>        paramDiscreteValue = Value
>>>>>
>>>>>        'Return paramDiscreteValue
>>>>>
>>>>>    End Function
>>>>>
>>>>>    Private Function CreateParameterRangeValue(ByVal StartRange As
>>>>> Object, ByVal EndRange As Object) As ParameterRangeValue
>>>>>        Dim paramRangeValue As ParameterRangeValue
>>>>>
>>>>>        paramRangeValue = New ParameterRangeValue
>>>>>
>>>>>        paramRangeValue.StartValue = StartRange
>>>>>        paramRangeValue.EndValue = EndRange
>>>>>
>>>>>        Return paramRangeValue
>>>>>    End Function
>>>>>
>>>>>
>>>>>    Private Sub cmdEerste_Click(ByVal sender As System.Object, ByVal e
>>>>> As System.EventArgs) Handles cmdEerste.Click
>>>>>        crViewer.ShowFirstPage()
>>>>>    End Sub
>>>>>
>>>>>    Private Sub cmdLaatste_Click(ByVal sender As System.Object, ByVal e
>>>>> As System.EventArgs) Handles cmdLaatste.Click
>>>>>        crViewer.ShowLastPage()
>>>>>    End Sub
>>>>>
>>>>>    Private Sub cmdTerug_Click(ByVal sender As System.Object, ByVal e
>>>>> As System.EventArgs) Handles cmdTerug.Click
>>>>>        crViewer.ShowPreviousPage()
>>>>>    End Sub
>>>>>
>>>>>    Private Sub cmdVerder_Click(ByVal sender As System.Object, ByVal e
>>>>> As System.EventArgs) Handles cmdVerder.Click
>>>>>        crViewer.ShowNextPage()
>>>>>    End Sub
>>>>>
>>>>>    Private Sub drpZoom_SelectedIndexChanged(ByVal sender As Object,
>>>>> ByVal e As System.EventArgs) Handles drpZoom.SelectedIndexChanged
>>>>>        crViewer.Zoom(drpZoom.SelectedItem.Value)
>>>>>    End Sub
>>>>>    Private Sub Page_Unload(ByVal sender As Object, ByVal e As
>>>>> System.EventArgs) Handles MyBase.Unload
>>>>>        Dim myExportFile As String =
>>>>> CType(Session.Item("exportbestand"), String)
>>>>>
>>>>>        System.IO.File.Delete(myExportFile)
>>>>>    End Sub
>>>>> End Class
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>
>>>>>> "Alison Givens" <i***@cross-it.nl> wrote in message
>>>>>> news:eeEqNEgNGHA.1288@TK2MSFTNGP09.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
>>>>>>> CrystalDecisions.Shared.ParameterField' cannot be converted
>>>>>>> to 'Crystal.Decisions.Shared.ParameterField'
>>>>>>>
>>>>>>> Return paramField
>>>>>>> The text is:
>>>>>>> Value of type 'CrystalDecisions.Shared.ParameterField' cannot be
>>>>>>> converted
>>>>>>> to '1 dimensional array of Crystal.Decisions.Shared.ParameterField'
>>>>>>>
>>>>>>> Same for
>>>>>>> paramField = CreateParamater("Periode")
>>>>>>> Return paramDiscreteValue
>>>>>>>
>>>>>>> Any idea what causes this?
>>>>>>>
>>>>>>> Alison
>>>>>>>
>>>>>>>
>>>>>>> "AMDRIT" <amd***@hotmail.com> wrote in message
>>>>>>> news:urCzE10MGHA.720@TK2MSFTNGP14.phx.gbl...
>>>>>>>> Wow, you do all that for Crystal Reports?  What is
>>>>>>>> RapportAIRCOStoringen?
>>>>>>>>
>>>>>>>>
>>>>>>>> Here is all I do for CR
>>>>>>>>
>>>>>>>> Dim x As CrystalDecisions.CrystalReports.Engine.ReportDocument
>>>>>>>>
>>>>>>>> x.Load(sReportPath) 'Reports are not embedded resources
>>>>>>>> x.SetParameterValue("Paramater1", Paramaters(1))      'Dynamic
>>>>>>>> Paramaters
>>>>>>>> x.SetParameterValue("Paramater2", Paramaters(2))
>>>>>>>> x.SetDataSource(mydata) 'Strongly Typed Datasets
>>>>>>>>
>>>>>>>> Me.CrystalReportViewer1.ReportSource = x
>>>>>>>> Me.CrystalReportViewer1.PrintReport()
>>>>>>>>
>>>>>>>>
>>>>>>>> '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.SetParameterValue("FiliaalKeuze", discreteVal)
>>>>>>>>
>>>>>>>> Why are you setting the crView paramaters and the myReport
>>>>>>>> paramaters?
>>>>>>>>  -->crViewer.ParameterFieldInfo = paramFields
>>>>>>>>  -->myReport.SetParameterValue("Periode", 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 RapportAIRCOStoringen
>>>>>>>>    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.QueryString("BeginPeriode")
>>>>>>>>      EindPeriode = Request.QueryString("EindPeriode")
>>>>>>>>    Catch ex As Exception
>>>>>>>>      Dim exCustom As ApplicationException
>>>>>>>>      exCustom = New ApplicationException("Unable to parse Query
>>>>>>>> Paramaters.", ex)
>>>>>>>>      Throw exCustom
>>>>>>>>    End Try
>>>>>>>>
>>>>>>>>    'Todo wrap in try
>>>>>>>>    paramField = CreateParamater("FiliaalKeuze")
>>>>>>>>    paramField.CurrentValues.Add(CreateParameterDiscreteValue(2044))
>>>>>>>>    paramField.CurrentValues.Add(CreateParameterDiscreteValue(2344))
>>>>>>>>    myReport.SetParameterValue("FiliaalKeuze", paramField)
>>>>>>>>    'paramFields.Add(paramField) --> Not needed
>>>>>>>>
>>>>>>>>    'Todo wrap in try
>>>>>>>>    paramField = CreateParamater("Periode")
>>>>>>>>
>>>>>>>> paramField.CurrentValues.Add(CreateParameterRangeValue(BeginPeriode,
>>>>>>>> EindPeriode))
>>>>>>>>    myReport.SetParameterValue("Periode", paramField)
>>>>>>>>    'paramFields.Add(paramField)--> Not needed
>>>>>>>>
>>>>>>>>    'Todo wrap in try, i don't think you need this
>>>>>>>>    'myReport.SetParameterValue("Periode", rangeVal)
>>>>>>>>    'myReport.SetParameterValue("FiliaalKeuze", discreteVal)
>>>>>>>>
>>>>>>>>    'Todo, determine if we need this step; I don't think you do
>>>>>>>>    'crViewer.ParameterFieldInfo = paramFields
>>>>>>>>
>>>>>>>>    crViewer.ReportSource = myReport
>>>>>>>>
>>>>>>>>  End Sub
>>>>>>>>
>>>>>>>>  Private Function CreateParamater(ByVal ParamaterName As String) As
>>>>>>>> ParameterField
>>>>>>>>    Dim paramField As ParameterField
>>>>>>>>
>>>>>>>>    paramField = New ParameterField
>>>>>>>>    paramField.ParameterFieldName = ParamaterName
>>>>>>>>
>>>>>>>>    Return paramField
>>>>>>>>
>>>>>>>>  End Function
>>>>>>>>
>>>>>>>>  Private Function CreateParameterDiscreteValue(ByVal Value As
>>>>>>>> Object) As ParameterDiscreteValue
>>>>>>>>
>>>>>>>>    Dim paramDiscreteValue As ParameterDiscreteValue
>>>>>>>>    paramDiscreteValue = New ParameterDiscreteValue
>>>>>>>>    paramDiscreteValue = Value
>>>>>>>>
>>>>>>>>    Return paramDiscreteValue
>>>>>>>>
>>>>>>>>  End Function
>>>>>>>>
>>>>>>>>  Private Function CreateParameterRangeValue(ByVal StartRange As
>>>>>>>> Object, ByVal EndRange As Object) As ParameterRangeValue
>>>>>>>>    Dim paramRangeValue As ParameterRangeValue
>>>>>>>>
>>>>>>>>    paramRangeValue = New ParameterRangeValue
>>>>>>>>
>>>>>>>>    paramRangeValue.StartValue = StartRange
>>>>>>>>    paramRangeValue.EndValue = EndRange
>>>>>>>>
>>>>>>>>    Return paramRangeValue
>>>>>>>>  End Function
>>>>>>>>
>>>>>>>> "Alison Givens" <i***@cross-it.nl> wrote in message
>>>>>>>> news:eW4b66tMGHA.668@TK2MSFTNGP11.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.QueryString("BeginPeriode")
>>>>>>>>> EindPeriode = Request.QueryString("EindPeriode")
>>>>>>>>>
>>>>>>>>> Dim myReport As New RapportAIRCOStoringen
>>>>>>>>>
>>>>>>>>> Dim paramFields As New ParameterFields
>>>>>>>>> Dim paramField As New ParameterField
>>>>>>>>> Dim discreteVal As New ParameterDiscreteValue
>>>>>>>>> Dim rangeVal As New ParameterRangeValue
>>>>>>>>>
>>>>>>>>> paramField.ParameterFieldName = "FiliaalKeuze"
>>>>>>>>> discreteVal.Value = "2044"
>>>>>>>>> paramField.CurrentValues.Add(discreteVal)
>>>>>>>>>
>>>>>>>>> discreteVal = New ParameterDiscreteValue
>>>>>>>>> discreteVal.Value = "2344"
>>>>>>>>> paramField.CurrentValues.Add(discreteVal)
>>>>>>>>>
>>>>>>>>> paramFields.Add(paramField)
>>>>>>>>>
>>>>>>>>> paramField = New ParameterField
>>>>>>>>>
>>>>>>>>> paramField.ParameterFieldName = "Periode"
>>>>>>>>>
>>>>>>>>> rangeVal.StartValue = BeginPeriode
>>>>>>>>> rangeVal.EndValue = EindPeriode
>>>>>>>>> paramField.CurrentValues.Add(rangeVal)
>>>>>>>>>
>>>>>>>>> paramFields.Add(paramField)
>>>>>>>>>
>>>>>>>>> crViewer.ParameterFieldInfo = paramFields
>>>>>>>>> myReport.SetParameterValue("Periode", rangeVal)
>>>>>>>>> myReport.SetParameterValue("FiliaalKeuze", discreteVal)
>>>>>>>>> crViewer.ReportSource = myReport
>>>>>>>>>
>>>>>>>>> As you can see I use myReport.SetParameterValue 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
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
Author
23 Feb 2006 9:07 AM
Alison Givens
Yepper, the web.config is case sensitive.
That solves that problem.
Next problem:
When I give in the parameters and go to the form that holds the report I get
this:

Value cannot be null. Parameter name: path
Description: An unhandled exception occurred during the execution of the
current web request.

Exception Details: System.ArgumentNullException: Value cannot be null.
Parameter name: path

Source Error:


Line 84:         Dim myExportFile As String =
CType(Session.Item("exportbestand"), String)
Line 85:
Line 86:         System.IO.File.Delete(myExportFile)
Line 87:     End Sub
Line 88:

I commented it, so I could at least try to go further.
Then when the form with the report loads, I get:
Unable to prepare report.

This comes out of this error handeling:
Try
   PrepareReport(myReport)
   Catch ex As Exception
   Dim exc As ApplicationException
   exc = New ApplicationException("Unable to prepare report.", ex)
   Throw exc
End Try

To be accurate I will put the entire current code here:


    Private Enum FileNameFormats
        SessionID = 0
        GUIDDashes = 1
        GUIDNoDashes = 2
    End Enum



    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
        Dim myReport As RapportAIRCOStoringen
        Dim myExportOptions As CrystalDecisions.Shared.ExportOptions

        Try

            Try
                PrepareReport(myReport)
            Catch ex As Exception
                Dim exc As System.ApplicationException
                exc = New System.ApplicationException("Unable to prepare
report.", ex)
                Throw exc
            End Try

            Try
                'exporteren to pdf
                myExportOptions =
GetExportOptions(FileNameFormats.GUIDNoDashes, CType(myReport,
CrystalDecisions.CrystalReports.Engine.ReportDocument).ExportOptions)
                myReport.Export()

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

            crViewer.ReportSource = myReport

            Session("exportbestand") =
CType(myExportOptions.DestinationOptions,
CrystalDecisions.Shared.DiskFileDestinationOptions).DiskFileName

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




    End Sub

#End Region

#Region "Page Implementation"

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

    Private Sub Page_Unload(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Unload
        'Dim myExportFile As String = CType(Session.Item("exportbestand"),
String)

        'System.IO.File.Delete(myExportFile)
    End Sub

#End Region

#Region "Report Setup"

    Private Sub PrepareReport(ByVal myReport As
CrystalDecisions.CrystalReports.Engine.ReportDocument)

        Dim paramFields As ParameterFields
        Dim paramField As ParameterField

        Const SessionExecption As String = "Unable to read session objects."

        Try

            paramFields = New ParameterFields
            Try
                paramField = CreateParameter("FiliaalKeuze")
                paramField.CurrentValues.Add(CreateParameterDiscreteValue(GetSessionValue("Filiaal")))
                'paramField.CurrentValues.Add(CreateParameterDiscreteValue(GetSessionValue("DiscreteValue2")))
            Catch ex As Exception
                Dim exc As ApplicationException
                exc = New ApplicationException(SessionExecption, ex)
                Throw exc
            End Try

            myReport.SetParameterValue("FiliaalKeuze", paramField)

            Try
                'Todo wrap in try
                paramField = CreateParameter("Periode")
                paramField.CurrentValues.Add(CreateParameterRangeValue(GetSessionValue("BeginPeriode"),
GetSessionValue("EindPeriode")))
            Catch ex As Exception
                Dim exc As System.ApplicationException
                exc = New System.ApplicationException(SessionExecption, ex)
                Throw exc
            End Try

            myReport.SetParameterValue("Periode", paramField)

        Catch ex As Exception

            Dim exc As System.ApplicationException
            exc = New System.ApplicationException("Unable 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.ParameterFieldName = ParameterName

        Return paramField

    End Function


    Private Function GetSessionValue(ByVal KeyName As String) As Object
        Try
            Return Session.Item(KeyName)
        Catch ex As Exception
            Dim exc As ApplicationException
            exc = New ApplicationException(String.Format("Unable to read
value from session:{0}", KeyName), ex)
            Throw exc
        End Try

    End Function



    Private Function CreateParameterDiscreteValue(ByVal Value As Object) As
ParameterDiscreteValue

        Dim paramDiscreteValue As ParameterDiscreteValue
        paramDiscreteValue = New ParameterDiscreteValue
        paramDiscreteValue = Value

        Return paramDiscreteValue

    End Function

    Private Function CreateParameterRangeValue(ByVal StartRange As Object,
ByVal EndRange As Object) As ParameterRangeValue
        Dim paramRangeValue As ParameterRangeValue

        paramRangeValue = New ParameterRangeValue

        paramRangeValue.StartValue = StartRange
        paramRangeValue.EndValue = EndRange

        Return paramRangeValue
    End Function

#End Region

#Region "Report Export"

    Private Function GetExportOptions(ByVal UniqueFormat As FileNameFormats,
ByVal ExportOptions As CrystalDecisions.Shared.ExportOptions) As
CrystalDecisions.Shared.ExportOptions

        Dim myExportFile As String
        Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
        Dim myDiskFileDestinationOptions As
CrystalDecisions.Shared.DiskFileDestinationOptions

        Try

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

            myExportFile = System.IO.Path.Combine(GetExportRoot(True),
String.Format("PDF_{0}.pdf", myExportFile))
            myDiskFileDestinationOptions = New
CrystalDecisions.Shared.DiskFileDestinationOptions
            myDiskFileDestinationOptions.DiskFileName = myExportFile

            myExportOptions = ExportOptions

            With myExportOptions
                .DestinationOptions = myDiskFileDestinationOptions
                .ExportDestinationType = .ExportDestinationType.DiskFile
                .ExportFormatType = .ExportFormatType.PortableDocFormat
            End With

        Catch ex As Exception

            Dim exc As System.ApplicationException
            exc = New System.ApplicationException("Unable to prepare export
options.", ex)
            Throw exc

        End Try

        Return myExportOptions

    End Function

    Private Function GetExportRoot(ByVal FromApplication As Boolean) As
String

        Dim strExportRoot As String

        If FromApplication Then
            Try
                Application.Lock()
                strExportRoot = Application("ReportExportRoot")
            Catch ex As Exception
                Dim exc As ApplicationException
                exc = New ApplicationException("Unable to lock Web
Application for read.", ex)
                Throw exc
            Finally
                Application.UnLock()
            End Try
        Else
            strExportRoot = Session("ReportExportRoot")
        End If

        Return strExportRoot

    End Function

#End Region

#Region "Navigation Implementation"

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

        Response.ClearContent()
        Response.ClearHeaders()
        Response.ContentType = "application/pdf"

        Dim myExportFile As String = CType(Session.Item("exportbestand"),
String)

        Response.WriteFile(myExportFile)
        Response.Flush()
        Response.Close()

        System.IO.File.Delete(myExportFile)

    End Sub

    Private Sub cmdEerste_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdEerste.Click
        crViewer.ShowFirstPage()
    End Sub

    Private Sub cmdLaatste_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdLaatste.Click
        crViewer.ShowLastPage()
    End Sub

    Private Sub cmdTerug_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdTerug.Click
        crViewer.ShowPreviousPage()
    End Sub

    Private Sub cmdVerder_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdVerder.Click
        crViewer.ShowNextPage()
    End Sub

    Private Sub drpZoom_SelectedIndexChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles drpZoom.SelectedIndexChanged
        crViewer.Zoom(drpZoom.SelectedItem.Value)
    End Sub

#End Region
Author
23 Feb 2006 4:18 PM
AMDRIT
I challenge you to consider what is going on and ask why would that type of
exception occur.

It appears that in your Page_Unload() you are attempting to do clean up.

    Private Sub Page_Unload(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Unload
        Dim myExportFile As String = CType(Session.Item("exportbestand"),
String)
        System.IO.File.Delete(myExportFile)
    End Sub

The problem is that the Session  item "exportbestand" appears to be
string.empty.  Perhaps, the value was never properly set.

The only place I see that you are setting the Session item is in page_init()

Session("exportbestand") =  CType _
(myExportOptions.DestinationOptions,
CrystalDecisions.Shared.DiskFileDestinationOptions).DiskFileName

You should test to see if DiskFileName has value, and if not, then work
backwards to where it is set to determine if a value is being set there.


Next, consider why the page_unload is firing without first displaying your
report.

try something like this in you error handling routine:

Try
   PrepareReport(myReport)
Catch ex As Exception
   dim innerEx as Exception, sb as system.text.stringbuilder
   sb = new system.text.stringbuilder

   sb.append(ex.tostring)

   innerEx = ex.innerexception

   do while not innerEx is nothing
     sb.append(vbcrlf)
     sb.append(innerEx.tostring)
     innerEx = innerEx.innerexception
   loop

   response.write(sb.tostring)
   response.end

   'exc = New ApplicationException("Unable to prepare report.", ex)
   'Throw exc
End Try


Show quoteHide quote
"Alison Givens" <i***@cross-it.nl> wrote in message
news:O0G6XiFOGHA.3576@TK2MSFTNGP15.phx.gbl...
> Yepper, the web.config is case sensitive.
> That solves that problem.
> Next problem:
> When I give in the parameters and go to the form that holds the report I
> get this:
>
> Value cannot be null. Parameter name: path
> Description: An unhandled exception occurred during the execution of the
> current web request.
>
> Exception Details: System.ArgumentNullException: Value cannot be null.
> Parameter name: path
>
> Source Error:
>
>
> Line 84:         Dim myExportFile As String =
> CType(Session.Item("exportbestand"), String)
> Line 85:
> Line 86:         System.IO.File.Delete(myExportFile)
> Line 87:     End Sub
> Line 88:
>
> I commented it, so I could at least try to go further.
> Then when the form with the report loads, I get:
> Unable to prepare report.
>
> This comes out of this error handeling:
> Try
>   PrepareReport(myReport)
>   Catch ex As Exception
>   Dim exc As ApplicationException
>   exc = New ApplicationException("Unable to prepare report.", ex)
>   Throw exc
> End Try
>
> To be accurate I will put the entire current code here:
>
>
>    Private Enum FileNameFormats
>        SessionID = 0
>        GUIDDashes = 1
>        GUIDNoDashes = 2
>    End Enum
>
>
>
>    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Init
>        'CODEGEN: This method call is required by the Web Form Designer
>        'Do not modify it using the code editor.
>        InitializeComponent()
>        Dim myReport As RapportAIRCOStoringen
>        Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
>
>        Try
>
>            Try
>                PrepareReport(myReport)
>            Catch ex As Exception
>                Dim exc As System.ApplicationException
>                exc = New System.ApplicationException("Unable to prepare
> report.", ex)
>                Throw exc
>            End Try
>
>            Try
>                'exporteren to pdf
>                myExportOptions =
> GetExportOptions(FileNameFormats.GUIDNoDashes, CType(myReport,
> CrystalDecisions.CrystalReports.Engine.ReportDocument).ExportOptions)
>                myReport.Export()
>
>            Catch ex As Exception
>                Dim exc As ApplicationException
>                exc = New ApplicationException("Unable to export report.",
> ex)
>                Throw exc
>            End Try
>
>            crViewer.ReportSource = myReport
>
>            Session("exportbestand") =
> CType(myExportOptions.DestinationOptions,
> CrystalDecisions.Shared.DiskFileDestinationOptions).DiskFileName
>
>        Catch err As Exception
>            Response.Write("<BR>")
>            Response.Write(err.Message.ToString)
>        End Try
>
>
>
>
>    End Sub
>
> #End Region
>
> #Region "Page Implementation"
>
>    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
>        'Put user code to initialize the page here
>    End Sub
>
>    Private Sub Page_Unload(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles MyBase.Unload
>        'Dim myExportFile As String = CType(Session.Item("exportbestand"),
> String)
>
>        'System.IO.File.Delete(myExportFile)
>    End Sub
>
> #End Region
>
> #Region "Report Setup"
>
>    Private Sub PrepareReport(ByVal myReport As
> CrystalDecisions.CrystalReports.Engine.ReportDocument)
>
>        Dim paramFields As ParameterFields
>        Dim paramField As ParameterField
>
>        Const SessionExecption As String = "Unable to read session
> objects."
>
>        Try
>
>            paramFields = New ParameterFields
>            Try
>                paramField = CreateParameter("FiliaalKeuze")
>
> paramField.CurrentValues.Add(CreateParameterDiscreteValue(GetSessionValue("Filiaal")))
>
> 'paramField.CurrentValues.Add(CreateParameterDiscreteValue(GetSessionValue("DiscreteValue2")))
>            Catch ex As Exception
>                Dim exc As ApplicationException
>                exc = New ApplicationException(SessionExecption, ex)
>                Throw exc
>            End Try
>
>            myReport.SetParameterValue("FiliaalKeuze", paramField)
>
>            Try
>                'Todo wrap in try
>                paramField = CreateParameter("Periode")
>
> paramField.CurrentValues.Add(CreateParameterRangeValue(GetSessionValue("BeginPeriode"),
> GetSessionValue("EindPeriode")))
>            Catch ex As Exception
>                Dim exc As System.ApplicationException
>                exc = New System.ApplicationException(SessionExecption, ex)
>                Throw exc
>            End Try
>
>            myReport.SetParameterValue("Periode", paramField)
>
>        Catch ex As Exception
>
>            Dim exc As System.ApplicationException
>            exc = New System.ApplicationException("Unable 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.ParameterFieldName = ParameterName
>
>        Return paramField
>
>    End Function
>
>
>    Private Function GetSessionValue(ByVal KeyName As String) As Object
>        Try
>            Return Session.Item(KeyName)
>        Catch ex As Exception
>            Dim exc As ApplicationException
>            exc = New ApplicationException(String.Format("Unable to read
> value from session:{0}", KeyName), ex)
>            Throw exc
>        End Try
>
>    End Function
>
>
>
>    Private Function CreateParameterDiscreteValue(ByVal Value As Object) As
> ParameterDiscreteValue
>
>        Dim paramDiscreteValue As ParameterDiscreteValue
>        paramDiscreteValue = New ParameterDiscreteValue
>        paramDiscreteValue = Value
>
>        Return paramDiscreteValue
>
>    End Function
>
>    Private Function CreateParameterRangeValue(ByVal StartRange As Object,
> ByVal EndRange As Object) As ParameterRangeValue
>        Dim paramRangeValue As ParameterRangeValue
>
>        paramRangeValue = New ParameterRangeValue
>
>        paramRangeValue.StartValue = StartRange
>        paramRangeValue.EndValue = EndRange
>
>        Return paramRangeValue
>    End Function
>
> #End Region
>
> #Region "Report Export"
>
>    Private Function GetExportOptions(ByVal UniqueFormat As
> FileNameFormats, ByVal ExportOptions As
> CrystalDecisions.Shared.ExportOptions) As
> CrystalDecisions.Shared.ExportOptions
>
>        Dim myExportFile As String
>        Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
>        Dim myDiskFileDestinationOptions As
> CrystalDecisions.Shared.DiskFileDestinationOptions
>
>        Try
>
>            Select Case UniqueFormat
>                Case FileNameFormats.SessionID
>                    myExportFile = Session.SessionID.ToString
>                Case FileNameFormats.GUIDDashes
>                    myExportFile = System.Guid.NewGuid.ToString("D")
>                Case FileNameFormats.GUIDNoDashes
>                    myExportFile = System.Guid.NewGuid.ToString("N")
>            End Select
>
>            myExportFile = System.IO.Path.Combine(GetExportRoot(True),
> String.Format("PDF_{0}.pdf", myExportFile))
>            myDiskFileDestinationOptions = New
> CrystalDecisions.Shared.DiskFileDestinationOptions
>            myDiskFileDestinationOptions.DiskFileName = myExportFile
>
>            myExportOptions = ExportOptions
>
>            With myExportOptions
>                .DestinationOptions = myDiskFileDestinationOptions
>                .ExportDestinationType = .ExportDestinationType.DiskFile
>                .ExportFormatType = .ExportFormatType.PortableDocFormat
>            End With
>
>        Catch ex As Exception
>
>            Dim exc As System.ApplicationException
>            exc = New System.ApplicationException("Unable to prepare export
> options.", ex)
>            Throw exc
>
>        End Try
>
>        Return myExportOptions
>
>    End Function
>
>    Private Function GetExportRoot(ByVal FromApplication As Boolean) As
> String
>
>        Dim strExportRoot As String
>
>        If FromApplication Then
>            Try
>                Application.Lock()
>                strExportRoot = Application("ReportExportRoot")
>            Catch ex As Exception
>                Dim exc As ApplicationException
>                exc = New ApplicationException("Unable to lock Web
> Application for read.", ex)
>                Throw exc
>            Finally
>                Application.UnLock()
>            End Try
>        Else
>            strExportRoot = Session("ReportExportRoot")
>        End If
>
>        Return strExportRoot
>
>    End Function
>
> #End Region
>
> #Region "Navigation Implementation"
>
>    Private Sub cmdPrint_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles cmdPrint.Click
>
>        Response.ClearContent()
>        Response.ClearHeaders()
>        Response.ContentType = "application/pdf"
>
>        Dim myExportFile As String = CType(Session.Item("exportbestand"),
> String)
>
>        Response.WriteFile(myExportFile)
>        Response.Flush()
>        Response.Close()
>
>        System.IO.File.Delete(myExportFile)
>
>    End Sub
>
>    Private Sub cmdEerste_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles cmdEerste.Click
>        crViewer.ShowFirstPage()
>    End Sub
>
>    Private Sub cmdLaatste_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles cmdLaatste.Click
>        crViewer.ShowLastPage()
>    End Sub
>
>    Private Sub cmdTerug_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles cmdTerug.Click
>        crViewer.ShowPreviousPage()
>    End Sub
>
>    Private Sub cmdVerder_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles cmdVerder.Click
>        crViewer.ShowNextPage()
>    End Sub
>
>    Private Sub drpZoom_SelectedIndexChanged(ByVal sender As Object, ByVal
> e As System.EventArgs) Handles drpZoom.SelectedIndexChanged
>        crViewer.Zoom(drpZoom.SelectedItem.Value)
>    End Sub
>
> #End Region
>
Author
27 Feb 2006 8:19 AM
Alison Givens
I used the error code as suggested in the PrepareReport.
This is the result:

System.ApplicationException: Unable to set paramatervalue. --->
System.ApplicationException: Unable to read session objects. --->
System.InvalidCastException: Specified cast is not valid. at
rapportage.ProductiviteitsLijst.CreateParameterDiscreteValue(Object Value)
in \\KP-COBRA\wwwroot$\rapportage\ProductiviteitsLijst.aspx.vb:line 177 at
rapportage.ProductiviteitsLijst.PrepareReport(ReportDocument myReport) in
\\KP-COBRA\wwwroot$\rapportage\ProductiviteitsLijst.aspx.vb:line 116 --- End
of inner exception stack trace --- at
rapportage.ProductiviteitsLijst.PrepareReport(ReportDocument myReport) in
\\KP-COBRA\wwwroot$\rapportage\ProductiviteitsLijst.aspx.vb:line 121 --- End
of inner exception stack trace --- at
rapportage.ProductiviteitsLijst.PrepareReport(ReportDocument myReport) in
\\KP-COBRA\wwwroot$\rapportage\ProductiviteitsLijst.aspx.vb:line 142 at
rapportage.ProductiviteitsLijst.Page_Init(Object sender, EventArgs e) in
\\KP-COBRA\wwwroot$\rapportage\ProductiviteitsLijst.aspx.vb:line 43
System.ApplicationException: Unable to read session objects. --->
System.InvalidCastException: Specified cast is not valid. at
rapportage.ProductiviteitsLijst.CreateParameterDiscreteValue(Object Value)
in \\KP-COBRA\wwwroot$\rapportage\ProductiviteitsLijst.aspx.vb:line 177 at
rapportage.ProductiviteitsLijst.PrepareReport(ReportDocument myReport) in
\\KP-COBRA\wwwroot$\rapportage\ProductiviteitsLijst.aspx.vb:line 116 --- End
of inner exception stack trace --- at
rapportage.ProductiviteitsLijst.PrepareReport(ReportDocument myReport) in
\\KP-COBRA\wwwroot$\rapportage\ProductiviteitsLijst.aspx.vb:line 121
System.InvalidCastException: Specified cast is not valid. at
rapportage.ProductiviteitsLijst.CreateParameterDiscreteValue(Object Value)
in \\KP-COBRA\wwwroot$\rapportage\ProductiviteitsLijst.aspx.vb:line 177 at
rapportage.ProductiviteitsLijst.PrepareReport(ReportDocument myReport) in
\\KP-COBRA\wwwroot$\rapportage\ProductiviteitsLijst.aspx.vb:line 116
Thread was being aborted.




















Show quoteHide quote
"AMDRIT" <amd***@hotmail.com> wrote in message
news:%23rPCuSJOGHA.3984@TK2MSFTNGP14.phx.gbl...
>I challenge you to consider what is going on and ask why would that type of
>exception occur.
>
> It appears that in your Page_Unload() you are attempting to do clean up.
>
>    Private Sub Page_Unload(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles MyBase.Unload
>        Dim myExportFile As String = CType(Session.Item("exportbestand"),
> String)
>        System.IO.File.Delete(myExportFile)
>    End Sub
>
> The problem is that the Session  item "exportbestand" appears to be
> string.empty.  Perhaps, the value was never properly set.
>
> The only place I see that you are setting the Session item is in
> page_init()
>
> Session("exportbestand") =  CType _
> (myExportOptions.DestinationOptions,
> CrystalDecisions.Shared.DiskFileDestinationOptions).DiskFileName
>
> You should test to see if DiskFileName has value, and if not, then work
> backwards to where it is set to determine if a value is being set there.
>
>
> Next, consider why the page_unload is firing without first displaying your
> report.
>
> try something like this in you error handling routine:
>
> Try
>   PrepareReport(myReport)
> Catch ex As Exception
>   dim innerEx as Exception, sb as system.text.stringbuilder
>   sb = new system.text.stringbuilder
>
>   sb.append(ex.tostring)
>
>   innerEx = ex.innerexception
>
>   do while not innerEx is nothing
>     sb.append(vbcrlf)
>     sb.append(innerEx.tostring)
>     innerEx = innerEx.innerexception
>   loop
>
>   response.write(sb.tostring)
>   response.end
>
>   'exc = New ApplicationException("Unable to prepare report.", ex)
>   'Throw exc
> End Try
>
>
> "Alison Givens" <i***@cross-it.nl> wrote in message
> news:O0G6XiFOGHA.3576@TK2MSFTNGP15.phx.gbl...
>> Yepper, the web.config is case sensitive.
>> That solves that problem.
>> Next problem:
>> When I give in the parameters and go to the form that holds the report I
>> get this:
>>
>> Value cannot be null. Parameter name: path
>> Description: An unhandled exception occurred during the execution of the
>> current web request.
>>
>> Exception Details: System.ArgumentNullException: Value cannot be null.
>> Parameter name: path
>>
>> Source Error:
>>
>>
>> Line 84:         Dim myExportFile As String =
>> CType(Session.Item("exportbestand"), String)
>> Line 85:
>> Line 86:         System.IO.File.Delete(myExportFile)
>> Line 87:     End Sub
>> Line 88:
>>
>> I commented it, so I could at least try to go further.
>> Then when the form with the report loads, I get:
>> Unable to prepare report.
>>
>> This comes out of this error handeling:
>> Try
>>   PrepareReport(myReport)
>>   Catch ex As Exception
>>   Dim exc As ApplicationException
>>   exc = New ApplicationException("Unable to prepare report.", ex)
>>   Throw exc
>> End Try
>>
>> To be accurate I will put the entire current code here:
>>
>>
>>    Private Enum FileNameFormats
>>        SessionID = 0
>>        GUIDDashes = 1
>>        GUIDNoDashes = 2
>>    End Enum
>>
>>
>>
>>    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles MyBase.Init
>>        'CODEGEN: This method call is required by the Web Form Designer
>>        'Do not modify it using the code editor.
>>        InitializeComponent()
>>        Dim myReport As RapportAIRCOStoringen
>>        Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
>>
>>        Try
>>
>>            Try
>>                PrepareReport(myReport)
>>            Catch ex As Exception
>>                Dim exc As System.ApplicationException
>>                exc = New System.ApplicationException("Unable to prepare
>> report.", ex)
>>                Throw exc
>>            End Try
>>
>>            Try
>>                'exporteren to pdf
>>                myExportOptions =
>> GetExportOptions(FileNameFormats.GUIDNoDashes, CType(myReport,
>> CrystalDecisions.CrystalReports.Engine.ReportDocument).ExportOptions)
>>                myReport.Export()
>>
>>            Catch ex As Exception
>>                Dim exc As ApplicationException
>>                exc = New ApplicationException("Unable to export report.",
>> ex)
>>                Throw exc
>>            End Try
>>
>>            crViewer.ReportSource = myReport
>>
>>            Session("exportbestand") =
>> CType(myExportOptions.DestinationOptions,
>> CrystalDecisions.Shared.DiskFileDestinationOptions).DiskFileName
>>
>>        Catch err As Exception
>>            Response.Write("<BR>")
>>            Response.Write(err.Message.ToString)
>>        End Try
>>
>>
>>
>>
>>    End Sub
>>
>> #End Region
>>
>> #Region "Page Implementation"
>>
>>    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles MyBase.Load
>>        'Put user code to initialize the page here
>>    End Sub
>>
>>    Private Sub Page_Unload(ByVal sender As Object, ByVal e As
>> System.EventArgs) Handles MyBase.Unload
>>        'Dim myExportFile As String = CType(Session.Item("exportbestand"),
>> String)
>>
>>        'System.IO.File.Delete(myExportFile)
>>    End Sub
>>
>> #End Region
>>
>> #Region "Report Setup"
>>
>>    Private Sub PrepareReport(ByVal myReport As
>> CrystalDecisions.CrystalReports.Engine.ReportDocument)
>>
>>        Dim paramFields As ParameterFields
>>        Dim paramField As ParameterField
>>
>>        Const SessionExecption As String = "Unable to read session
>> objects."
>>
>>        Try
>>
>>            paramFields = New ParameterFields
>>            Try
>>                paramField = CreateParameter("FiliaalKeuze")
>>
>> paramField.CurrentValues.Add(CreateParameterDiscreteValue(GetSessionValue("Filiaal")))
>>
>> 'paramField.CurrentValues.Add(CreateParameterDiscreteValue(GetSessionValue("DiscreteValue2")))
>>            Catch ex As Exception
>>                Dim exc As ApplicationException
>>                exc = New ApplicationException(SessionExecption, ex)
>>                Throw exc
>>            End Try
>>
>>            myReport.SetParameterValue("FiliaalKeuze", paramField)
>>
>>            Try
>>                'Todo wrap in try
>>                paramField = CreateParameter("Periode")
>>
>> paramField.CurrentValues.Add(CreateParameterRangeValue(GetSessionValue("BeginPeriode"),
>> GetSessionValue("EindPeriode")))
>>            Catch ex As Exception
>>                Dim exc As System.ApplicationException
>>                exc = New System.ApplicationException(SessionExecption,
>> ex)
>>                Throw exc
>>            End Try
>>
>>            myReport.SetParameterValue("Periode", paramField)
>>
>>        Catch ex As Exception
>>
>>            Dim exc As System.ApplicationException
>>            exc = New System.ApplicationException("Unable 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.ParameterFieldName = ParameterName
>>
>>        Return paramField
>>
>>    End Function
>>
>>
>>    Private Function GetSessionValue(ByVal KeyName As String) As Object
>>        Try
>>            Return Session.Item(KeyName)
>>        Catch ex As Exception
>>            Dim exc As ApplicationException
>>            exc = New ApplicationException(String.Format("Unable to read
>> value from session:{0}", KeyName), ex)
>>            Throw exc
>>        End Try
>>
>>    End Function
>>
>>
>>
>>    Private Function CreateParameterDiscreteValue(ByVal Value As Object)
>> As ParameterDiscreteValue
>>
>>        Dim paramDiscreteValue As ParameterDiscreteValue
>>        paramDiscreteValue = New ParameterDiscreteValue
>>        paramDiscreteValue = Value
>>
>>        Return paramDiscreteValue
>>
>>    End Function
>>
>>    Private Function CreateParameterRangeValue(ByVal StartRange As Object,
>> ByVal EndRange As Object) As ParameterRangeValue
>>        Dim paramRangeValue As ParameterRangeValue
>>
>>        paramRangeValue = New ParameterRangeValue
>>
>>        paramRangeValue.StartValue = StartRange
>>        paramRangeValue.EndValue = EndRange
>>
>>        Return paramRangeValue
>>    End Function
>>
>> #End Region
>>
>> #Region "Report Export"
>>
>>    Private Function GetExportOptions(ByVal UniqueFormat As
>> FileNameFormats, ByVal ExportOptions As
>> CrystalDecisions.Shared.ExportOptions) As
>> CrystalDecisions.Shared.ExportOptions
>>
>>        Dim myExportFile As String
>>        Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
>>        Dim myDiskFileDestinationOptions As
>> CrystalDecisions.Shared.DiskFileDestinationOptions
>>
>>        Try
>>
>>            Select Case UniqueFormat
>>                Case FileNameFormats.SessionID
>>                    myExportFile = Session.SessionID.ToString
>>                Case FileNameFormats.GUIDDashes
>>                    myExportFile = System.Guid.NewGuid.ToString("D")
>>                Case FileNameFormats.GUIDNoDashes
>>                    myExportFile = System.Guid.NewGuid.ToString("N")
>>            End Select
>>
>>            myExportFile = System.IO.Path.Combine(GetExportRoot(True),
>> String.Format("PDF_{0}.pdf", myExportFile))
>>            myDiskFileDestinationOptions = New
>> CrystalDecisions.Shared.DiskFileDestinationOptions
>>            myDiskFileDestinationOptions.DiskFileName = myExportFile
>>
>>            myExportOptions = ExportOptions
>>
>>            With myExportOptions
>>                .DestinationOptions = myDiskFileDestinationOptions
>>                .ExportDestinationType = .ExportDestinationType.DiskFile
>>                .ExportFormatType = .ExportFormatType.PortableDocFormat
>>            End With
>>
>>        Catch ex As Exception
>>
>>            Dim exc As System.ApplicationException
>>            exc = New System.ApplicationException("Unable to prepare
>> export options.", ex)
>>            Throw exc
>>
>>        End Try
>>
>>        Return myExportOptions
>>
>>    End Function
>>
>>    Private Function GetExportRoot(ByVal FromApplication As Boolean) As
>> String
>>
>>        Dim strExportRoot As String
>>
>>        If FromApplication Then
>>            Try
>>                Application.Lock()
>>                strExportRoot = Application("ReportExportRoot")
>>            Catch ex As Exception
>>                Dim exc As ApplicationException
>>                exc = New ApplicationException("Unable to lock Web
>> Application for read.", ex)
>>                Throw exc
>>            Finally
>>                Application.UnLock()
>>            End Try
>>        Else
>>            strExportRoot = Session("ReportExportRoot")
>>        End If
>>
>>        Return strExportRoot
>>
>>    End Function
>>
>> #End Region
>>
>> #Region "Navigation Implementation"
>>
>>    Private Sub cmdPrint_Click(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles cmdPrint.Click
>>
>>        Response.ClearContent()
>>        Response.ClearHeaders()
>>        Response.ContentType = "application/pdf"
>>
>>        Dim myExportFile As String = CType(Session.Item("exportbestand"),
>> String)
>>
>>        Response.WriteFile(myExportFile)
>>        Response.Flush()
>>        Response.Close()
>>
>>        System.IO.File.Delete(myExportFile)
>>
>>    End Sub
>>
>>    Private Sub cmdEerste_Click(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles cmdEerste.Click
>>        crViewer.ShowFirstPage()
>>    End Sub
>>
>>    Private Sub cmdLaatste_Click(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles cmdLaatste.Click
>>        crViewer.ShowLastPage()
>>    End Sub
>>
>>    Private Sub cmdTerug_Click(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles cmdTerug.Click
>>        crViewer.ShowPreviousPage()
>>    End Sub
>>
>>    Private Sub cmdVerder_Click(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles cmdVerder.Click
>>        crViewer.ShowNextPage()
>>    End Sub
>>
>>    Private Sub drpZoom_SelectedIndexChanged(ByVal sender As Object, ByVal
>> e As System.EventArgs) Handles drpZoom.SelectedIndexChanged
>>        crViewer.Zoom(drpZoom.SelectedItem.Value)
>>    End Sub
>>
>> #End Region
>>
>
>
Author
27 Feb 2006 4:43 PM
AMDRIT
Hello Alison,

Take a look at what the exception output is telling you.

System.InvalidCastException: Specified cast is not valid. at
rapportage.ProductiviteitsLijst.CreateParameterDiscreteValue(Object Value)

If we take a look at the mechanics of that function, you will see:

-->Define variable <-- set's the contract of the object we want, as long as
we hold a reference to the appropriate library we should be fine with this
line of code

-->Create variable <-- just like frakenstien, bring it to life.  It is
possible to screw up here, especially if the New() is expecting input.

-->Assign some value to the Value property <-- Here we can screw up by
assigning a value type to the property that is not convertible to the
desired type.  Or, we could simply neglect to specify which property we wish
to modify, in which case we would be trying to change the contract of the
variable.

If you take a closer inspection, you should not that the code does not
attempt to assign a value to the Value() property, rather it attempts to
assign the value to the object itself.  So in effect, we made space for a
ParameterDiscreteValue and attempted to change it into a string.

If you turn on Option Strict (easiest way is to type Option Strict On, at
the top of your code pane; before any other text), issues like this will be
revealed before you compile.  The downside to doing this is that you will
loose all of your implicit type conversions that VB does for you.  That
means:

dim objString as string
objString = 6
(This will produce compiler error, since VB will not try to convert a number
'Integer' into a string.)

Becomes

dim objString as string
objString = 6.ToString
(Please note that all objects have a ToString method, however; not all will
provide the String like number types will.  Example:  a datatable.tostring
will return something like "system.data.datatable" rather than the data
inside the object.)

or

dim objString as string
objString = ctype(6,string)
(Please note that there are two generic type converters, CType and
DirectCast, look them up as homework, You should get into practice of using
them as a matter of process.)

If you are using C#, instead of ctype you can create the conversion as such:

String objString=String.Empty;
objString = (string)6;
(I  don't know what that is called, I just think it is cool.  Eitherway, it
solves for Option Strict issues.)


It appears that your problem is here

Private Function CreateParameterDiscreteValue(ByVal Value As Object)  As
ParameterDiscreteValue

        Dim paramDiscreteValue As ParameterDiscreteValue
        paramDiscreteValue = New ParameterDiscreteValue
        paramDiscreteValue = Value

        Return paramDiscreteValue

End Function

Should be

Private Function CreateParameterDiscreteValue(ByVal Value As Object)  As
ParameterDiscreteValue

        Dim paramDiscreteValue As ParameterDiscreteValue
        paramDiscreteValue = New ParameterDiscreteValue

        '--==>Assign Value to the value property, not the object.'<==--
        paramDiscreteValue.Value = Value

        Return paramDiscreteValue


End Function


Let me know if any of this is not clear.