Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. trouble in passing parameter in crystal document

trouble in passing parameter in crystal document

Scheduled Pinned Locked Moved Visual Basic
helpcsharpcomdata-structures
12 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A aguest

    i am getting some trouble with a tutorial that i found on msdn web site : http://msdn.microsoft.com/en-us/library/ms227722.aspx. i would like to pass a parameter to my CrystalReport document,but i would like to send an integer value to my CR document and just one value(because in the tut its sending and array of string values). the code is the fellowing

    Private Const PARAMETER_FIELD_NAME As String = "numb"

    Private impbonrecepReport As ReportDocument
    
    Private Sub ConfigureCrystalReports()
    
    
        Dim myArrayList As ArrayList = New ArrayList()
    
        myArrayList.Add(999)
        Dim numbrecep As Integer
    
        numbrecep = 999
    
    
    
        SetCurrentValuesForParameterField(impbonrecepReport, myArrayList)
       
        impbonrecepReport = New ReportDocument()
        Dim reportPath As String = Application.StartupPath & "\\" & "ImpBonReception.rpt"
    
        impbonrecepReport.Load(reportPath)
        CrystalReportViewer1.ReportSource = impbonrecepReport
    
    End Sub
    

    Private Sub SetCurrentValuesForParameterField(ByVal myReportDocument As ReportDocument, ByVal myArrayList As ArrayList)

        Dim currentParameterValues As ParameterValues = New ParameterValues()
    
    
        For Each submittedValue As Object In myArrayList
    
            Dim myParameterDiscreteValue As ParameterDiscreteValue = New ParameterDiscreteValue()
            myParameterDiscreteValue.Value = myArrayList.ToString()
            currentParameterValues.Add(myParameterDiscreteValue)
    
        Next
    
    
        Dim myParameterFieldDefinitions As ParameterFieldDefinitions = myReportDocument.DataDefinition.ParameterFields
        Dim myParameterFieldDefinition As ParameterFieldDefinition = myParameterFieldDefinitions(PARAMETER\_FIELD\_NAME)
        myParameterFieldDefinition.ApplyCurrentValues(currentParameterValues)
    
    
    End Sub
    

    i got this error message

    An unhandled exception of type 'System.NullReferenceException' occurred in GestionStock.exe
    Additional information: La référence d'objet n'est pas définie à une instance d'un objet.

    in this line Dim myParameterFieldDefinitions As ParameterFieldDefinitions = myReportDocument.DataDefinition.ParameterFields can you help me to solve this problem? thank you ps: i am on VS2005 VB.NET

    T Offline
    T Offline
    tosch
    wrote on last edited by
    #2

    Move the call to SetCurrentValuesForParameterField to the line after loading the report. This should fix your problem.

    Tosch

    A 1 Reply Last reply
    0
    • T tosch

      Move the call to SetCurrentValuesForParameterField to the line after loading the report. This should fix your problem.

      Tosch

      A Offline
      A Offline
      aguest
      wrote on last edited by
      #3

      now i getting a message error in the next line Dim myParameterFieldDefinition As ParameterFieldDefinition = myParameterFieldDefinitions(PARAMETER_FIELD_NAME) this is the error message An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in CrystalDecisions.CrystalReports.Engine.dll Additional information: Index non valide. (Exception de HRESULT : 0x8002000B (DISP_E_BADINDEX))

      T 1 Reply Last reply
      0
      • A aguest

        now i getting a message error in the next line Dim myParameterFieldDefinition As ParameterFieldDefinition = myParameterFieldDefinitions(PARAMETER_FIELD_NAME) this is the error message An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in CrystalDecisions.CrystalReports.Engine.dll Additional information: Index non valide. (Exception de HRESULT : 0x8002000B (DISP_E_BADINDEX))

        T Offline
        T Offline
        tosch
        wrote on last edited by
        #4

        You're trying to get an item with the name PARAMETER_FIELD_NAME from your myParameterFieldDefinitions. Does it exist in the collection? Probably not, as the error says 'Index not valid'

        Tosch

        A 1 Reply Last reply
        0
        • T tosch

          You're trying to get an item with the name PARAMETER_FIELD_NAME from your myParameterFieldDefinitions. Does it exist in the collection? Probably not, as the error says 'Index not valid'

          Tosch

          A Offline
          A Offline
          aguest
          wrote on last edited by
          #5

          i fellowed the first part of this tutorial to set myParameterFieldDefinitions : LINK TO THE TUT and i have in my table(the table linked o the crystalReport Document) field called numb that i assigned it to PARAMETER_FIELD_NAME . and still dont know where is the error ???

          T 1 Reply Last reply
          0
          • A aguest

            i fellowed the first part of this tutorial to set myParameterFieldDefinitions : LINK TO THE TUT and i have in my table(the table linked o the crystalReport Document) field called numb that i assigned it to PARAMETER_FIELD_NAME . and still dont know where is the error ???

            T Offline
            T Offline
            tosch
            wrote on last edited by
            #6

            Please loop through myParameterFieldDefinitions and check if any member is called numb (your fieldname). I'm not sure what the propertyname is, probably name or fieldname.

            Tosch

            A 1 Reply Last reply
            0
            • T tosch

              Please loop through myParameterFieldDefinitions and check if any member is called numb (your fieldname). I'm not sure what the propertyname is, probably name or fieldname.

              Tosch

              A Offline
              A Offline
              aguest
              wrote on last edited by
              #7

              I coudnt find any thing cause the error hapend in this line Dim myParameterFieldDefinition As ParameterFieldDefinition = myParameterFieldDefinitions(PARAMETER_FIELD_NAME) i looked for numb or name and fieldname but nothing ????

              T 1 Reply Last reply
              0
              • A aguest

                I coudnt find any thing cause the error hapend in this line Dim myParameterFieldDefinition As ParameterFieldDefinition = myParameterFieldDefinitions(PARAMETER_FIELD_NAME) i looked for numb or name and fieldname but nothing ????

                T Offline
                T Offline
                tosch
                wrote on last edited by
                #8

                Please check the property ParameterFieldName. You may have to loop through all items in ParameterFieldDefinitions and check the value of ParameterFieldName. What are the values for this field?

                Tosch

                A 1 Reply Last reply
                0
                • T tosch

                  Please check the property ParameterFieldName. You may have to loop through all items in ParameterFieldDefinitions and check the value of ParameterFieldName. What are the values for this field?

                  Tosch

                  A Offline
                  A Offline
                  aguest
                  wrote on last edited by
                  #9

                  sorry to bother you with an other problem,but now that i moved at home and i working on my pc (OS:windows 7)i got an error message with the same code : An unhandled exception of type 'System.Exception' occurred in CrystalDecisions.CrystalReports.Engine.dll Additional information: Load report failed. on this line impbonrecepReport.Load(reportPath)

                  T 1 Reply Last reply
                  0
                  • A aguest

                    sorry to bother you with an other problem,but now that i moved at home and i working on my pc (OS:windows 7)i got an error message with the same code : An unhandled exception of type 'System.Exception' occurred in CrystalDecisions.CrystalReports.Engine.dll Additional information: Load report failed. on this line impbonrecepReport.Load(reportPath)

                    T Offline
                    T Offline
                    tosch
                    wrote on last edited by
                    #10

                    Does the report that you pass to the load function exist?

                    Tosch

                    A 1 Reply Last reply
                    0
                    • T tosch

                      Does the report that you pass to the load function exist?

                      Tosch

                      A Offline
                      A Offline
                      aguest
                      wrote on last edited by
                      #11

                      i just found a property called ParamName and it's equal=Nothing. the other probelm happend with me when i work on windows 7 but when i worked with winXp i dont get this message error.

                      A 1 Reply Last reply
                      0
                      • A aguest

                        i just found a property called ParamName and it's equal=Nothing. the other probelm happend with me when i work on windows 7 but when i worked with winXp i dont get this message error.

                        A Offline
                        A Offline
                        aguest
                        wrote on last edited by
                        #12

                        is that not normal that can be empty(ParamName=Nothing)? please can you give me a hand

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups