Click to See Complete Forum and Search --> : Some problems with Runtime of CR8


Akademos
August 9th, 2000, 06:22 AM
Hi I have a programm in which i display reports in CRViewer. To avoid the "Memory-Full"-Bug of CR8 i have designed the prog as a MDI-Project in which for every report choosen a new MDI-Childwindow with a CRViewer-Form is opened. This works fine until i use reports which own subreports. when i use them my prog hangs after CRViewer.ViewReport. Here's the code, perhaps you find an error


public Function bOpenReport(CRVwr as CRViewer, byval PageIndex as Integer, byval ButtonKey as string, byval ButtonIndex as Integer, dlg as Form) as Boolean
on error GoTo err_Handler
Dim m_vntRptPk as ReportSourceRouter
Dim iNoOfGroups as Integer
Dim m_ReportFileName as string
Dim iTable as Integer

Dim spTable as CRAXDRT.DatabaseTable
Dim crSections as CRAXDRT.Sections
Dim crSection as CRAXDRT.Section
Dim crSubreportObj as CRAXDRT.SubreportObject
Dim crSubreport as CRAXDRT.Report
Dim crReportObjects as CRAXDRT.ReportObjects
Dim ReportObject as Object

set m_vntRptPk = new ReportSourceRouter

CRVwr.Visible = false

Screen.MousePointer = vbHourglass
m_strCurrentPage = PAGE_NAME & PageIndex
m_strCurrentReport = REPORT_NAME & ButtonIndex

m_creClass.OpenKey LocalMachine, RegistryKey
m_strReportName = m_creClass.ReadValue("Name")
iNoOfGroups = m_creClass.ReadValue("NumberOfGroups")
m_ReportFileName = App.Path & m_creClass.ReadValue("Path")

set m_rpt = m_appTheApp.OpenReport(m_ReportFileName, 1)

If m_rpt.HasSavedData then m_rpt.DiscardSavedData

'Connectionstring holen
m_creClass.OpenKey LocalMachine, "Registrykey"
m_strConnString = m_creClass.ReadValue("CONNECTION")

set crSections = m_rpt.Sections

for Each crSection In crSections
set crReportObjects = crSection.ReportObjects

for Each ReportObject In crReportObjects
Debug.print ReportObject.Kind
If ReportObject.Kind = crSubreportObject then
set crSubreportObj = ReportObject
set crSubreport = crSubreportObj.OpenSubreport

for iTable = 1 to crSubreport.Database.Tables.Count
set m_adorsRecord = new ADODB.Recordset
set spTable = m_rpt.Database.Tables(iTable)

m_adorsRecord.Open spTable.Name, m_strConnString, adOpenStatic, adLockReadOnly, adCmdTable

If Not spTable.TestConnectivity = true then
MsgBox "Funktion CReportManager: TestConnectivit für SubReport fehlgeschlagen."
End If

spTable.SetDataSource m_adorsRecord, 3
next iTable



set m_adorsRecord = nothing
End If
next
next

for iTable = 1 to m_rpt.Database.Tables.Count

set m_adorsRecord = new ADODB.Recordset
set spTable = m_rpt.Database.Tables(iTable)

m_adorsRecord.Open spTable.Name, m_strConnString, adOpenStatic, adLockReadOnly, adCmdTable
Debug.print spTable.Name

If Not m_rpt.Database.Tables(iTable).TestConnectivity = true then
MsgBox "Funktion bOpenReport: TestConnectivity fehlgeschlagen"
End If

spTable.SetDataSource m_adorsRecord, 3

set m_adorsRecord = nothing
next iTable



m_rpt.Database.Verify
m_rpt.EnableParameterPrompting = false
Screen.MousePointer = vbDefault
If Not iNoOfGroups = 0 then
dlg.Show vbModal
End If


m_vntRptPk.AddReport m_rpt
Screen.MousePointer = vbHourglass
CRVwr.ReportSource = m_vntRptPk
DoEvents
CRVwr.ViewReport
DoEvents
CRVwr.DisplayGroupTree = false
CRVwr.DisplayToolbar = false
m_creClass.CloseKey
CRVwr.Visible = true
Screen.MousePointer = vbDefault
bOpenReport = true
Exit Function
err_Handler:

MsgBox "Untreated error in Funktion bOpenReport: " & vbCrLf & Err.Description & vbCrLf & Err.Number
bOpenReport = false
End Function




It could also be that the error lays in the reports itself. As i designed them with ADO-Connectivity it has only one recordset called 'ado' and and the tables used in the reports are aliases on this one recordset

Thanks for help

akademos

Akademos
August 9th, 2000, 09:43 AM
I think i'm a step further. As i found out CR gernerates automatically for each subreport a recordset or table called 'ado_1', 'ado_1_1' usw. my prog reads it as normal tables and try to connect them with my database which of course don't own such tables. But if I avoid those tables it also don't load me reports but print some Errormessage. Does anyone of you know how to solve this?

Thanks

akademos