Hi,
I have never had trouble passing values to Crystal Reports in the past, however for some reason none of my code that passes parameter values to Crystal Reports is working anymore. The only difference in my applications is that I recently converted them to VS2005 from VS2003. But I do not know if that would cause my code to stop working. Here is a quick and easy sample of the code I use to pass these parameters.
Any ideas whats wrong here?
Thanks,
Razzle
I have never had trouble passing values to Crystal Reports in the past, however for some reason none of my code that passes parameter values to Crystal Reports is working anymore. The only difference in my applications is that I recently converted them to VS2005 from VS2003. But I do not know if that would cause my code to stop working. Here is a quick and easy sample of the code I use to pass these parameters.
Code:
Private Sub CreateReport()
Dim cnSQL As New SqlConnection(ccStrings.Conn3.ConnectionString)
Dim daSQL As SqlDataAdapter = New SqlDataAdapter
Dim ds As New DataSet
Dim strSQL As String = ""
Dim RptDoc As New ReportDocument
Dim pvCollection As New CrystalDecisions.Shared.ParameterValues
Dim pdvItem As New CrystalDecisions.Shared.ParameterDiscreteValue
strSQL = "SELECT access,last_name,first_name " & _
"FROM basic " & _
"WHERE agency='1'"
Dim cmSQL As New SqlCommand(strSQL, cnSQL)
daSQL.SelectCommand = cmSQL
If IsNothing(ds.Tables("ReportTest")) = False Then
ds.Tables("ReportTest").Clear()
End If
daSQL.Fill(ds, "ReportTest")
RptDoc.Load("C:\TestVS2005\ReportTest.rpt")
pdvItem.Value = "Test Parameter Value"
pvCollection.Add(pdvItem)
RptDoc.DataDefinition.ParameterFields("@title1").ApplyCurrentValues(pvCollection)
RptDoc.SetDataSource(ds)
CrystalReportViewer1.ReportSource = RptDoc
CrystalReportViewer1.Visible = True
End Sub
Any ideas whats wrong here?
Thanks,
Razzle