
Invalid Report Source Error in Crystal Report Viewer
Hi there ,
well can any body please let me know what wrong i m doing in the below
code ..
i am getting INVALID REPORT SOURCE ERROR
when i try to Launch the Report
i m using VB.Net and SQL-Server 2000 as database
the below code use to work fine with Msaccess database
thanks in advance..
Brij
***********************************************
'Crystal Report Variables
Dim crReport1 As crReport1
Dim crTableLogonInfo As TableLogOnInfo
Dim crConnectionInfo As ConnectionInfo
Dim crTable As Table
Private sub Load Report
crReport1= New crReport1()
SetDatabaseLocation(CType(crReport1, ReportDocument))
crReport1.PrintOptions.PaperOrientation = PaperOrientation.Portrait
crViewer.ReportSource = crReport1
end sub
Public Sub SetDatabaseLocation(ByRef crReport As ReportDocument)
Dim crTableLogonInfo As New TableLogOnInfo()
Dim crConnectionInfo As New ConnectionInfo()
Dim crTable As Table
Dim crSections As Sections
Dim crSection As Section
Dim crReportObjects As ReportObjects
Dim crReportObject As ReportObject
Dim crSubreportObject As SubreportObject
Dim crSubreportDocument As ReportDocument
crConnectionInfo.DatabaseName = "NorthWind"
crConnectionInfo.ServerName = "Local"
crConnectionInfo.UserID = "sa"
crConnectionInfo.Password = ""
crTableLogonInfo.ConnectionInfo = crConnectionInfo
With crReport
For Each crTable In crReport.Database.Tables
crTable.ApplyLogOnInfo(crTableLogonInfo)
Next
For Each crSection In .ReportDefinition.Sections
crReportObjects = crSection.ReportObjects
For Each crReportObject In crReportObjects
If crReportObject.Kind =
ReportObjectKind.SubreportObject Then
crSubreportObject = CType(crReportObject,
SubreportObject)
crSubreportDocument =
crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)
For Each crTable In
crSubreportDocument.Database.Tables
crTable.ApplyLogOnInfo(crTableLogonInfo)
Next
End If
Next
Next
End With
crTableLogonInfo = Nothing
crConnectionInfo = Nothing
crTable = Nothing
crSections = Nothing
crSection = Nothing
crReportObjects = Nothing
crReportObject = Nothing
crSubreportObject = Nothing
crSubreportDocument = Nothing
End Sub