Visual Studio 2010 VB .net
latest Crystal API version
Win 7
looking for a sample to get past the sub report issue described below.
I am having no problem making all of the connection changes I need in the main report, but when I move to a report that has a subreport several of the calls that I made in the main report are not supported in a subreport.
ReportAppServer {"Not supported within subreports."}
ReportClientDocument {"Not supported within subreports."}
ReportDefinition {CrystalDecisions.CrystalReports.Engine.ReportDefinition}
I did find a sample doc(1795120) in C# referred to by Don Williams but cannot seem to get rid of all of the errors.
I iterate through all of the objects in the report to fine the subreports and then proceed to make my changes, but as I stated earlier many of the calls are not supported in subreports. I appreciate any assistance
From here on is just an example of the code that does work to modify the main report.
Here is some of the code that changes all of the tables connection information in the main report. I am changing from an older Access Driver and need to apply the accdb name and location as it always changes. One again this code works
boReportDocument.Load(ReportLocation, OpenReportMethod.OpenReportByTempCopy)
Dim boTable As New CrystalDecisions.ReportAppServer.DataDefModel.Table
Dim boMainPropertyBag As New PropertyBag
Dim boInnerPropertyBag As New PropertyBag
boInnerPropertyBag.Add("Connection String", "Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=" + DataLocation + ";")
boInnerPropertyBag.Add("Trusted_Connection", "0")
boInnerPropertyBag.Add("UseDSNProperties", "False")
'----------------------------------------------------
'Set the attributes for the boMainPropertyBag
boMainPropertyBag.Add("Database DLL", "crdb_odbc.dll")
boMainPropertyBag.Add("QE_DatabaseName", "")
boMainPropertyBag.Add("QE_DatabaseType", "ODBC (RDO)") '----------------------------------------------------
'Add the QE_LogonProperties we set in the boInnerPropertyBag Object
boMainPropertyBag.Add("QE_LogonProperties", boInnerPropertyBag)
boMainPropertyBag.Add("QE_ServerDescription", "Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=" + DataLocation + ";")
boMainPropertyBag.Add("QE_SQLDB", "True")
boMainPropertyBag.Add("SSO Enabled", "False")
Dim boConnectionInfo As New CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo
'Pass the database properties to a connection info object
boConnectionInfo.Attributes = boMainPropertyBag
boConnectionInfo.Kind = CrConnectionInfoKindEnum.crConnectionInfoKindCRQE
boConnectionInfo.UserName = ""
boConnectionInfo.Password = ""
boTable.ConnectionInfo = boConnectionInfo
'Capture the Database Tables in your report
Dim boTables As CrystalDecisions.ReportAppServer.DataDefModel.Tables = boReportDocument.ReportClientDocument.DatabaseController.Database.Tables
Dim i As Integer = 0
For Each table As CrystalDecisions.ReportAppServer.DataDefModel.Table In boTables
boTable.Name = table.Name.ToString
boTable.QualifiedName = table.QualifiedName.ToString
boTable.Alias = table.Alias.ToString
boReportDocument.ReportClientDocument.DatabaseController.SetTableLocation(table, boTable)
Next