Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error Opening Reports that have SubReports

Status
Not open for further replies.

peter1812

Programmer
Aug 13, 2003
4
0
0
CA
Can you guys suggest any reason that I might be getting errors when I try to open a report that contains a subreport?

I've tried opening these reports (there are a number of them) both through ASP (by modifying the RAS9 samples) and through VB. Everything works fine, so long as the report doesn't contain a subreport. If it does, I get an error trying to open the report (Note: Before any interaction with the database/parameters is done, so I don't think that's contributing to the problem).

Each time, it fails on the Report (or ReportClientDocument).Open line, kicking back an error number 0x80004003 with a reason of either "Automation error, Invalid pointer" (ASP, and some in VB) or "Method 'Open' of 'ISCDReportClientDocument' failed." (VB).

The reports were written in CR 8.5 and converted to 9.0 (the datasources were also updated to use SQLOLEDB as a provider when this was done since it refused to work at all with ODBC).

Configuration:
Reports in CR9 format, stored on the RAS, being opened from a client machine through either ASP or VB. Data is being pulled from a SQLServer database. If there are any other details I can provide, please let me know.
 
I've already gone through the samples you linked to. They only work for reports that don't have sub reports.

The problem that I'm having is opening reports with subreports. (Not using them with the samples).

Crystal's example 'SimpleSubReportLogin' works, but when I change it to use one of our reports with a sub-report it fails.

What I'm asking is are there any reason that this could be occuring?
 
hi
i think you cant caal a subreport that has a subreport


pgtek
 
'=========================================================================================
'
' CHANGING DATABASE INFO AT RUNTIME
'
' Some things to note about the code below:
'
' 1. It gets only the first connection info found in the report. If your report/subreports
' contains more than one data source, this code will have to be modified accordingly
'
' 2. Crystal Reports 9 stores the fully-qualified table name and one of the other things
' this sample does is change the table name from fully-qualified to the simple table name
'
' 3. This example demonstrates how to change the database for ODBC - it will need to be modified
' to get it to work for OLE DB.
'
'==========================================================================================

'Set the NEW Information: DSN, database, username, and password
DSNName = "dsnname"
Database = "Dbname"
username = "user"
password = "pass"


' Get the connection information from the report document for the first table in the collection
Set oDBInfo = Session("oClientDoc").DatabaseController.GetConnectionInfos().Item(0)

' Get the connection info attributes
Set pbLevel1 = oDBInfo.Attributes

'This 'first level' property bag will be used to define the basic database info for the report
pbLevel1.Item("QE_ServerDescription") = Database

With pbLevel1
.Item("Database Name") = Database
.Item("Server Name") = DSNName
.Item("Server Type") = "ODBC - " & DSNName
End With

'This 'second level' property bag contains info that is specific to the type of db connection
'in this case, it will contain our OLE DB specific information
Set pbLevel2 = pbLevel1.item("QE_LogonProperties")
pbLevel2.Item("DSN") = DSNName

'Attaching the QE specific properties to the 'level 1' property bag
pbLevel1.Item("QE_LogonProperties") = pbLevel2

'Add thew new property bag info to the connection object (and set the username/password)
oDBInfo.Attributes = pbLevel1
oDBInfo.UserName = username
oDBInfo.Password = password
'===============================================================
' CHANGING THE MAIN REPORT DATABASE INFO
'===============================================================

'Get the collection of tables in the main report
Set Tables = Session("oClientDoc").DataDefController.Database.Tables
For Each table in Tables

'clone the table object
Set newTable = Table.Clone

'set the table's connectionInfo to the current connection info
newTable.ConnectionInfo = oDBInfo

'set the table object qualified name to include the new database name
'i.e. original = 'db1.dbo.myTable', new = 'db2.dbo.myTable'
newTable.QualifiedName = Database & ".dbo." & Table.Name

'put this newly modified table object back into the report client doc
Session("oClientDoc").DatabaseController.SetTableLocation table, newTable

Next


'===============================================================
' CHANGING THE DATABASE FOR ALL SUBREPORTS
'===============================================================

'get a collection of subreport names
Set subReportNames = Session("oClientDoc").SubReportController.QuerySubreportNames

For each subName in subReportnames

'we can't reference a subreport table object directly, so we get the collection of tables first
Set subTables = Session("oClientDoc").SubReportController.GetSubreportDatabase(subName).Tables

For each subTable in subTables

'clone the subreport table object
Set newSubTable = subTable.Clone

'set the subreport table's connectionInfo to the current connection info
newSubTable.ConnectionInfo = oDBInfo

'set the table object qualified name to include the new database name
'i.e. original = 'db1.dbo.myTable', new = 'db2.dbo.myTable'
newSubTable.QualifiedName = Database & ".dbo." & subTable.Name

'put this newly modified table object back into the report client doc
Session("oClientDoc").SubReportController.SetTableLocation subName, subTable, newSubTable
Next
Next
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top