Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing parameter values to crystal reports

Status
Not open for further replies.

Razzle00

Programmer
Sep 27, 2006
20
US
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.

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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top