Reputation: 1
I use VB.net 2010 and Crystal Report XI. I want to load the report in a report viewer, but when i open the rpt file in crystal reports designer, the report viewer in vb.net give error : load report failed.
But when i close the crystal report software or just close the rpt file from crystal reports software, then the report viewer can run just fine. Do i really have to close crystal reports every time i want to open the rpt file from report viewer in vb.net.?
In case of being needed, this is my code:
Dim Report As New ReportDocument
Dim Report1 As New ReportDocument
Dim li As New TableLogOnInfo
Dim tbs As Tables
Dim tb As Table
Try
Report.Load(reportLocation & filename)
li.ConnectionInfo.DatabaseName = dbname
li.ConnectionInfo.UserID = userid
li.ConnectionInfo.Password = password
li.ConnectionInfo.ServerName = servername
tbs = Report.Database.Tables
For Each tb In Report.Database.Tables
tb.ApplyLogOnInfo(li)
Next
Report.RecordSelectionFormula += IIf(Report.RecordSelectionFormula <> "", " and ", "") & formula
Report.Refresh()
Report.SetParameterValue(0, param(0))
Report.SetParameterValue(1, param(1))
Report.SetParameterValue(2, param(2))
If param(3) <> "" Then Report.SetParameterValue(3, param(3))
crV.ReportSource = Report
crV.Show()
Catch ex As Exception
MsgBox(ex.Message)
End Try
In case of being asked, I use windows 10 and SQL Server 2008 R2 SP2.
Upvotes: 0
Views: 5496
Reputation: 1
go to the properties of the crystal report and under to copy to output directory select copy always
Upvotes: 0
Reputation: 1
I decided to move back to Windows 7, and in win 7 i didn't get any of these problem. Maybe its more like compatibility issue or something. So i think, case closed.
Upvotes: 0
Reputation: 4211
Check your report path; this is your problem. The System cannot find that the report exists.
This one specifically:
<pre>
Report.Load(reportLocation & filename)
check it using string variable like this;
string getpath = reportLocation & filename;
just check it if its location is the same by checking getpath variable
secondly: crystal report need to login to your working database thats why it says load report failed.
if this one working well then you dont have any problem regarding the crystal report path:
tbs = Report.Database.Tables
For Each tb In Report.Database.Tables
tb.ApplyLogOnInfo(li)
Next
</pre>
Upvotes: 0