I am trying to write a generic VB application to display Crystal reports with parameters. I can get it to display the a report with stored data but get "Server has not yet been opened" when I resubmit the report. I am using RDC. I have looked at the Automation Server but this requires additional coding to pass the parameters to the reports. Do I have to use the Automation Server to accomplish this?
Option Explicit
Dim m_Application As New CRAXDDRT.Application
Dim m_Report As New CRAXDDRT.Report
'Dim m_Application As New CRPEAuto.Application
'Dim m_Report As New CRPEAuto.Report
'Dim m_Report As New CrystalReport1
Dim datacmd1 As ADODB.Command
Dim i As Integer
'DisplayReport is a procedure that
' - Sets the report object to the Crystal Report Viewer Control
Public Sub DisplayReport()
Screen.MousePointer = vbHourglass
CRViewer1.ReportSource = m_Report
' Set the viewer to view the report
CRViewer1.ViewReport
' Set the zoom level to fit the page
' to the width of the viewer window
CRViewer1.Zoom 1
Screen.MousePointer = vbDefault
End Sub
Private Sub cmdOpenReport_Click()
CommonDialog1.CancelError = True
On Error GoTo errHandler
'Display the open dialog box
CommonDialog1.ShowOpen
' Build the ADO connection string
'strConnectString = "Provider=MSDAORA;Data Source=prod" + _
' ";User ID=userid;Password=password"
'If OpenConnection() = False Then
' MsgBox "Unable to Logon", , "Logon Failed"
'End If
'Set the report object to nothing
Set m_Report = Nothing
'Set m_Application = CreateObject("Crystal.CRPE.Application"
'Open the selected report
Set m_Report = m_Application.OpenReport(CommonDialog1.FileName, 1)
'm_Report.Preview ("Hercules"
' m_Report.Database.Tables(1).SetDataSource rsRecordSet, 3
'm_Report.Database.Tables(1).SetLogOnInfo "", "", "", "userPassword"
'm_Report.Database.Tables(1).SetLogOnInfo "lawsonprod", "prod", "userid", "password"
'm_Report.Database.LogOnServer "pdsodbc.dll", "prod.world", "prod", "Lawsonprod", "Mustangs"
Call DisplayReport
Set m_Report = Nothing
Set m_Application = Nothing
Exit Sub
errHandler:
'User cancalled dialog
End Sub
Option Explicit
Dim m_Application As New CRAXDDRT.Application
Dim m_Report As New CRAXDDRT.Report
'Dim m_Application As New CRPEAuto.Application
'Dim m_Report As New CRPEAuto.Report
'Dim m_Report As New CrystalReport1
Dim datacmd1 As ADODB.Command
Dim i As Integer
'DisplayReport is a procedure that
' - Sets the report object to the Crystal Report Viewer Control
Public Sub DisplayReport()
Screen.MousePointer = vbHourglass
CRViewer1.ReportSource = m_Report
' Set the viewer to view the report
CRViewer1.ViewReport
' Set the zoom level to fit the page
' to the width of the viewer window
CRViewer1.Zoom 1
Screen.MousePointer = vbDefault
End Sub
Private Sub cmdOpenReport_Click()
CommonDialog1.CancelError = True
On Error GoTo errHandler
'Display the open dialog box
CommonDialog1.ShowOpen
' Build the ADO connection string
'strConnectString = "Provider=MSDAORA;Data Source=prod" + _
' ";User ID=userid;Password=password"
'If OpenConnection() = False Then
' MsgBox "Unable to Logon", , "Logon Failed"
'End If
'Set the report object to nothing
Set m_Report = Nothing
'Set m_Application = CreateObject("Crystal.CRPE.Application"
'Open the selected report
Set m_Report = m_Application.OpenReport(CommonDialog1.FileName, 1)
'm_Report.Preview ("Hercules"
' m_Report.Database.Tables(1).SetDataSource rsRecordSet, 3
'm_Report.Database.Tables(1).SetLogOnInfo "", "", "", "userPassword"
'm_Report.Database.Tables(1).SetLogOnInfo "lawsonprod", "prod", "userid", "password"
'm_Report.Database.LogOnServer "pdsodbc.dll", "prod.world", "prod", "Lawsonprod", "Mustangs"
Call DisplayReport
Set m_Report = Nothing
Set m_Application = Nothing
Exit Sub
errHandler:
'User cancalled dialog
End Sub