Help loading Crystal Reports Viewer Control

jimmyray

Member
Joined
Dec 30, 2009
Messages
14
Programming Experience
Beginner
I am trying to load a crystal report viewer control on my form. This is my code and I get an error. Specified Cast Is Not Valid I know what the error means, but not sure how to find it. Here is my code.

Private Sub frmReportExportPDF_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim DS As New DataSet

'Get the Report Location
Dim strReportPath As String = "C:\Malatex\ARS\Reports\PatientCareReport.rpt"

'Check if file exists
If Not IO.File.Exists(strReportPath) Then

Throw (New Exception("Unable to locate report file:" & vbCrLf & strReportPath))

End If

'Assign the datasource and set the properties for Report viewer
Dim rptDocument As New PatientCareReport

Try
rptDocument.Load(strReportPath)
DS.ReadXml("C:\PCRReport.xml")
rptDocument.SetDataSource(DS)
CRViewer.ReportSource = rptDocument


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

End Sub
 
Back
Top