Click here to Skip to main content
15,886,718 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a report which I want to pass a datetime parameter and display that parameter into the report. I have a code but then the field in the repost is still blank.

VB
Dim paramFields As New ParameterFields
               Dim paramField1 As New ParameterField
               Dim paramField2 As New ParameterField
               Dim discreteVal As New ParameterDiscreteValue


               discreteVal.Value = odDatumPicker.Value
               paramField1.ParameterFieldName = "@Datum"
               paramField1.CurrentValues.Add(discreteVal)
               paramFields.Add(paramField1)

    
               CrystalReportViewer1.ParameterFieldInfo = paramFields
Posted

1 solution

You can use the below code to generate the report.
VB
Dim crReportDoc As New ReportDocument()
Dim crpConnectionInfo As New ConnectionInfo()
crReportDoc.Load(FilePath)
crpConnectionInfo.AllowCustomConnection = True
crpConnectionInfo.ServerName = [servername]
crpConnectionInfo.DatabaseName = [dbname]
crpConnectionInfo.UserID = [username]
crpConnectionInfo.Password = [password]

For Each tblCurrent In _crReportDoc.Database.Tables
    crpTableLogonInfo = tblCurrent.LogOnInfo
    crpTableLogonInfo.ConnectionInfo = crpConnectionInfo
    tblCurrent.ApplyLogOnInfo(crpTableLogonInfo)
Next
crReportDoc.VerifyDatabase()
crReportDoc.SetParameterValue("@Datum", odDatumPicker.Value)
CrystalReportViewer1.ReportSource = crReportDoc

Please change the ConnectionInfo
 
Share this answer
 
v2

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