Click here to Skip to main content
15,878,003 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi All
I have been trying to solve passing parameters in Cyrstal report,

What I have done is :

1) I added cyrstal repot in my project,

2) I connect with database using OLE DB (ADO) in database Expert form (For your kind information; I did not create or add DataSet1.xsd file the cyrstal report worked on below code with out parameters and I want report with parameter)

3) I added below piece of code on my form load event


When I try to pass parameter using .SetparameterValue Function, report pop up with bunch of values BUT it does not filter with values which I want



Here is helping images

Error Image
Crystal report look
DB Connecion

PLEASE HELP ME, I HAVE BEEN TRYING TO SOLVE THIS CODE SINCE 2 MONTHS

VB
Public Class frmrptProducts

    Private Sub frmrptProducts_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        
        Dim cryRpt As New ReportDocument
        Dim CrTables As Tables
        Dim crtableLogoninfo As New TableLogOnInfo
        Dim crConnectionInfo As New ConnectionInfo

        'Try

        'load report
        cryRpt.Load(ReportPath & "CRproducts.rpt")

        'parameters definition(if any)
        Dim ColourName As String = "White"
        cryRpt.SetParameterValue("colours", ColourName)

        'provide connection info. This is important and you can change it as per your db location
        With crConnectionInfo
            .ServerName = My.Application.Info.DirectoryPath.ToString() & "\data\db.mdb"
            '.DatabaseName = ""
            '.UserID = ""
            .Password = ""
        End With

        CrTables = cryRpt.Database.Tables
        For Each CrTable In CrTables
            crtableLogoninfo = CrTable.LogOnInfo
            crtableLogoninfo.ConnectionInfo = crConnectionInfo
            CrTable.ApplyLogOnInfo(crtableLogoninfo)

        Next


        CRV.ReportSource = cryRpt
        CRV.Refresh()

        'Catch ex As Exception
        '    MsgBox(ex.Message)
        'End Try

    End Sub




Posted
Updated 6-Jul-14 7:40am
v2
Comments
DamithSL 6-Jul-14 13:46pm    
what is the error and where you use this parameter in your report? i think you better check few articles or tutorials first
Tutorial[^]
Keval Savani 7-Jul-14 5:46am    
hiI have display parameter code in above, still here it is :

'parameters definition(if any)
Dim ColourName As String = "White"
cryRpt.SetParameterValue("colours", ColourName)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900