Spider_Monkey
04-14-2004, 09:22 AM
I have been trying to get a pre-developed crystal report to display in a VB6 app at runtime. I can get the report to display with saved data, but when ever I use the .DiscardSavedData method and try to refresh the data I get an error message. The message is this "Server has not been opened". This is my first encounter with this version of Crystal 8.5, so I am sure that I am not using a certain method that is needed. Another question I had is do I even need to open an ADO recordset to populate the report?
Also, one other thing to point out is that my report is using to different tables from with in the same database.
=======================================================
'Declare GS Connection
Public cnGS As New ADODB.Connection
'Declare Connection String Variable
Public sGSConString As String
'Declare ADO record set
Public rsSelect As New ADODB.Recordset
Public rsExec As New ADODB.Recordset
'Declare SQL query string
Public sSQLSelect As String
Public sSQLExec As String
' Declare the application object
Public crxApplication As New CRAXDRT.Application
' Declare report object
Public crxReport As CRAXDRT.Report
Private Sub cmdViewReport_Click()
Call LoadReport
End Sub
Private Sub Form_Load()
Call OpenDatabase
End Sub
Public Function LoadReport()
Set crxReport = New CRAXDRT.Report
Set crxApplication = CreateObject("crystalruntime.application")
Set crxReport = crxApplication.OpenReport("C:\Report1Test.rpt", 1)
crxReport.DiscardSavedData
crxReport.Database.SetDataSource rsSelect
crvViewer.ReportSource = crxReport
crvViewer.ViewReport
End Function
Public Function OpenDatabase()
'Setup the GS database connection
Set cnGOS = New ADODB.Connection
sGSConString = "Provider=SQLOLEDB.1;Persist Security Info=True;User ID=noway;Password=nohow;Initial Catalog=GR;Data Source=GS"
cnGS.ConnectionString = sGSConString
cnGS.Open
cnGS.CursorLocation = adUseClient
sSQLSelect = "SELECT * FROM OMDR"
rsSelect.Open sSQLSelect, cnGS, adOpenDynamic, adLockReadOnly
rsSelect.MoveFirst
End Function
========================================================
Any suggestions would be appreciated!
:eek:
Also, one other thing to point out is that my report is using to different tables from with in the same database.
=======================================================
'Declare GS Connection
Public cnGS As New ADODB.Connection
'Declare Connection String Variable
Public sGSConString As String
'Declare ADO record set
Public rsSelect As New ADODB.Recordset
Public rsExec As New ADODB.Recordset
'Declare SQL query string
Public sSQLSelect As String
Public sSQLExec As String
' Declare the application object
Public crxApplication As New CRAXDRT.Application
' Declare report object
Public crxReport As CRAXDRT.Report
Private Sub cmdViewReport_Click()
Call LoadReport
End Sub
Private Sub Form_Load()
Call OpenDatabase
End Sub
Public Function LoadReport()
Set crxReport = New CRAXDRT.Report
Set crxApplication = CreateObject("crystalruntime.application")
Set crxReport = crxApplication.OpenReport("C:\Report1Test.rpt", 1)
crxReport.DiscardSavedData
crxReport.Database.SetDataSource rsSelect
crvViewer.ReportSource = crxReport
crvViewer.ViewReport
End Function
Public Function OpenDatabase()
'Setup the GS database connection
Set cnGOS = New ADODB.Connection
sGSConString = "Provider=SQLOLEDB.1;Persist Security Info=True;User ID=noway;Password=nohow;Initial Catalog=GR;Data Source=GS"
cnGS.ConnectionString = sGSConString
cnGS.Open
cnGS.CursorLocation = adUseClient
sSQLSelect = "SELECT * FROM OMDR"
rsSelect.Open sSQLSelect, cnGS, adOpenDynamic, adLockReadOnly
rsSelect.MoveFirst
End Function
========================================================
Any suggestions would be appreciated!
:eek: