ashan ashan -3 years ago 104
Vb.net Question

Crystal Report does not load

My Crystal Report does not load.

This is my code:

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

Public Class bincard
Private Sub bincard_Load(sender As Object, e As EventArgs) Handles MyBase.Load

End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs)
Dim cryRpt As New ReportDocument

cryRpt.Load(Application.StartupPath + "bincard1.rpt")

Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldDefinition As ParameterFieldDefinition
Dim crParameterValues As New ParameterValues
Dim crParameterDiscreteValue As New ParameterDiscreteValue

crParameterDiscreteValue.Value = TextBox1.Text
crParameterFieldDefinitions =
cryRpt.DataDefinition.ParameterFields
crParameterFieldDefinition =
crParameterFieldDefinitions.Item("itemid")
crParameterValues = crParameterFieldDefinition.CurrentValues

crParameterValues.Clear()
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)

CrystalReportViewer1.ReportSource = cryRpt
CrystalReportViewer1.Refresh()
End Sub
End Class

Answer Source
cryRpt.Load(Application.StartupPath & "bincard1.rpt")

Then report design set to copy output directory=copy if newer and compile to content.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download