borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2010 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (data report or crystal report?)Next Topic (page totals in crystal reports) New Topic New Poll Post Reply
AndreaVB Forum : Reporting tools : vb.net pass parameters to crystal reports
Poster Message
jazzgirl
Level: Trainee

Registered: 21-03-2009
Posts: 1

Ads by Lake Quincy Media
icon vb.net pass parameters to crystal reports

  How should I pass 2 parameters from a  vb.net 2005 windows application to a crystal report that is written in version 11?
  I am working on a Visual Basic.NET 2005 windows application. This application needs to call an existing crystal report written in version 11 and needs to pass two (2) parameters to the crystal report.
  When I step though the code I think I am passing the first parameter, and I know that I am not passing the second parameter. I am getting an error message on the second when I step though the code.
  My code is basically the following (except I do not know how to code the second parameter)
mports CrystalDecisions.Shared
Imports CrystalDecisions.ReportSource
Imports CrystalDecisions.Windows.Forms
Imports System.Data.SqlClient

Public Class vbCls
  
    Dim cryRpt As New ReportDocument
  
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
        Dim cryRpt As New ReportDocument
        Dim sql As String
        Dim connetionString As String
        Dim connection As SqlConnection
        Dim adapter As SqlDataAdapter
        Dim ds As New DataSet
        Dim i As Integer
        'located crystal report from
        Dim strReportPath As String = "C:\TstReport.rpt"
                connetionString = "Data Source=server3;Initial
Catalog=ProgTest;User ID=xxx;Password=xxxx"
        connection = New SqlConnection(connetionString)
        sql = "select * from test_table"

        Try
            connection.Open()
            adapter = New SqlDataAdapter(sql, connection)
            adapter.Fill(ds)
            connection.Close()
                      
                cryRpt.Load(strReportPath)
                        
                Dim crParameterFieldDefinitions As ParameterFieldDefinitions
                Dim crParameterFieldDefinition As ParameterFieldDefinition
                Dim crParameterValues As New ParameterValues
                Dim crParameterDiscreteValue As New ParameterDiscreteValue
                              
                crParameterDiscreteValue.Value = 12345
                crParameterFieldDefinitions = _
                cryRpt.DataDefinition.ParameterFields
                crParameterFieldDefinition = _
                crParameterFieldDefinitions.Item("@Id")
                crParameterValues = crParameterFieldDefinition.CurrentValues

                crParameterValues.Clear()
                crParameterValues.Add(crParameterDiscreteValue)
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)

                CrystalReportViewer1.ReportSource = cryRpt
                CrystalReportViewer1.Refresh()
              
                  Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Sub

End Class


  The error message I am getting every time I try to code a second parameter is pass is the following:
crystaldecisions.crystalreports.engine.ParameterFieldCurrentValueException: Missing parameter values
-->System.Runtime.InteropServices.ComException (0x8004100E): Missing paramter value

21-03-2009 at 06:13 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Reporting tools : vb.net pass parameters to crystal reports
Previous Topic (data report or crystal report?)Next Topic (page totals in crystal reports) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2010 Andrea Tincaniborder