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.
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.