D
douglas
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 values.
Thanks!
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 values.
Thanks!