cancel
Showing results for 
Search instead for 
Did you mean: 

Passing Parameter to Crystal Report

Former Member
0 Kudos

Hi Experts,

I have created and designed a Report in Crystal Report 2005. I am displaying the report in SAP B1 using Win Form . Here I want to pass 2 parameters to Report ---@FromDate and @ToDate . I have coded to pass these two parameters this way :

Dim RptDoc As New ReportDocument

Dim ParamValue As String = String.Empty

Dim crtableLogoninfos As New CrystalDecisions.Shared.TableLogOnInfos

Dim crtableLogoninfo As New CrystalDecisions.Shared.TableLogOnInfo

Dim crConnectionInfo As New CrystalDecisions.Shared.ConnectionInfo

Dim CrTables As CrystalDecisions.CrystalReports.Engine.Tables

Dim CrTable As CrystalDecisions.CrystalReports.Engine.Table

Try

RptDoc.Load(Application.StartupPath() & "\" & ReportName & ".rpt")

RptDoc.SetParameterValue("@FromDate", "01/01/2008")

RptDoc.SetParameterValue("@ToDate", "12/31/2008")

Dim oForm_ReportViewer As Frm_ReportViewer = New Frm_ReportViewer()

oForm_ReportViewer.CRViewer.ReportSource = RptDoc

With crConnectionInfo

.ServerName = oCompany.Server '"(local)"

.DatabaseName = oCompany.CompanyDB '"SBODemoIn"

.UserID = oCompany.DbUserName

.Password = "manager@123" 'oCompany.DbPassword

End With

CrTables = RptDoc.Database.Tables

'Loop through each table in the report and apply the

'LogonInfo information

For Each CrTable In CrTables

crtableLogoninfo = CrTable.LogOnInfo

crtableLogoninfo.ConnectionInfo = crConnectionInfo

CrTable.ApplyLogOnInfo(crtableLogoninfo)

Next

oForm_ReportViewer.Text = frmTitle

oForm_ReportViewer.WindowState = FormWindowState.Maximized

oForm_ReportViewer.ShowDialog()

Catch Ex As Exception

MessageBox.Show(Ex.ToString)

End Try

But When I view the report in B1 , it throws an Exception "Report or Procedure expects parameter @FromDate which is not supplied. "

Please help me where I am making mistake , what could be the cause of this exception..

Thanks and Regards,

Pooja Singh.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Pooja Singh,

You have only set Dim ParamValue As String = String.Empty. Where are two parameter @FromDate and @ToDate?

SetParameterValue will only work if you have defined the parameters already and the parameters have the right format.

You may check this thread:

Thanks,

Gordon