ESH
asked on
Launching a simple report from VB.Net
Hi, I am trying to launch a Crystal report from VB.Net code. I have used 2 approaches:
Method 1: Created a form with a CrystalReportViewer control. Then, in the caller function, I put this:
-------------------------- ---------- ----
Dim frmCrys As New CrystalForm()
Dim oRpt As New Crystal.CrystalReport()
oRpt.ReportFileName = "EDILOG1.rpt"
oRpt.ReportSource = Crystal.ReportSourceConsta nts.crptRe port
frmCrys.CRViewer1.ReportSo urce = oRpt
frmCrys.ShowDialog()
-------------------------- ---------- ----
The result of this is a message from the Viewer saying: Invalid Report Source.
(The rpt file is where it's supposed to be and works independently)
Method 2:
-------------------------- ---------- ----
Dim cr1 As New Crystal.CrystalReport()
With cr1
.ReportFileName = "EDILOG1.rpt"
.DiscardSavedData = True
.Action = 1
End With
-------------------------- ---------- ----
This one gives me an COMexception which says: "Exception from HRESULT: 0x800A5035."
Debugging:ErrorCode is -2146807755
source is "Interop.Crystal"
How do I do this right? Am on the right track with either of these approaches?
As with everything at work, this has instantly become urgent, so even though it's probably easy, I'll offer 250 points.
Method 1: Created a form with a CrystalReportViewer control. Then, in the caller function, I put this:
--------------------------
Dim frmCrys As New CrystalForm()
Dim oRpt As New Crystal.CrystalReport()
oRpt.ReportFileName = "EDILOG1.rpt"
oRpt.ReportSource = Crystal.ReportSourceConsta
frmCrys.CRViewer1.ReportSo
frmCrys.ShowDialog()
--------------------------
The result of this is a message from the Viewer saying: Invalid Report Source.
(The rpt file is where it's supposed to be and works independently)
Method 2:
--------------------------
Dim cr1 As New Crystal.CrystalReport()
With cr1
.ReportFileName = "EDILOG1.rpt"
.DiscardSavedData = True
.Action = 1
End With
--------------------------
This one gives me an COMexception which says: "Exception from HRESULT: 0x800A5035."
Debugging:ErrorCode is -2146807755
source is "Interop.Crystal"
How do I do this right? Am on the right track with either of these approaches?
As with everything at work, this has instantly become urgent, so even though it's probably easy, I'll offer 250 points.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Never mind, I found what the last problem was. Points have been split evenly. I appreciate the help given. Thanks.
Glad to help.
ASKER
I have not put a password on this database, so I don't know why it should fail.
Is this a requirement of doing it through this method? When I open the report directly it doesn't ask for a password.