on 10-13-2008 9:21 PM
I have some CR 8.5 reports with subreport. I used to have codes to open the subreport database connection.
Set crSecs = Report.Sections
For i = 1 To crSecs.Count
Set crSec = crSecs.Item(i)
Set crRepObjs = crSec.ReportObjects
For x = 1 To crRepObjs.Count
If crRepObjs.Item(x).Kind = crSubreportObject Then
Set crSubReport = Report.OpenSubreport(crRepObjs.Item(x).SubreportName)
'the following code sets the subreport table to a different database
crSubReport.Database.Tables(1).SetLogOnInfo DataSource, strPUser, strPass
End If
Next
Next
Now I am using CR 11 and the code no longer works. My subreport doesn't refresh the data according to the database I used.
Any suggestion will be greatly appreciated.
Thanks
Thanks a lot. It works great.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Shweta
Thank you and I will try the code. One quick question do you know if we can still use CRAXDRT? I am using CR Viewer. I tried all the reference and component I can think of and I still can't use CRAXDRT in CR 11.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Yongling,
Have a look to :
[Sample Codes|https://boc.sdn.sap.com/codesamples] and [SDK Library|https://www.sdn.sap.com/irj/sdn/businessobjects-sdklibrary]
Hope this helps!!
Regards,
Shweta
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Yongling,
We need to pass database logon code for both Main report and Subreport
/*Database Logon for the main report*/
ConnectionInfo crConnectionInfo = new ConnectionInfo();
crConnectionInfo.ServerName = "SERVER";
crConnectionInfo.DatabaseName = "DATABASE";
crConnectionInfo.UserID = "USERID";
crConnectionInfo.Password = "PASSWORD";
// Use a loop to go through all the tables in the main report
foreach(Table crTable in crReportDocument.Database.Tables)
{
// Get the TableLogOnInfo from the Table and then set the new
// ConnectionInfo values.
TableLogOnInfo crLogOnInfo = crTable.LogOnInfo;
crLogOnInfo.ConnectionInfo = crConnectionInfo;
// Apply the TableLogOnInfo
crTable.ApplyLogOnInfo(crLogOnInfo);
// Set the location of the database. This value will vary from // database to database.
crTable.Location = "DATABASE.OWNER.TABLENAME";
}
/*Database Logon for a subreport*/
ConnectionInfo crConnectionInfo = new ConnectionInfo();
crConnectionInfo.ServerName = "SERVER";
crConnectionInfo.DatabaseName = "DATABASE";
crConnectionInfo.UserID = "USERID";
crConnectionInfo.Password = "PASSWORD";
// Loop through the ReportObjects in a report and find all the subreports
foreach(ReportObject crReportObject in crReportDocument.ReportDefinition.ReportObjects)
{
// Check the kind of the ReportObject, if it is a subreport
// proceed. If not skip.
if(crReportObject.Kind == ReportObjectKind.SubreportObject)
{
// Get the SubReport in the form of a ReportDocument
string sSubreportName = ((SubreportObject)crReportObject).SubreportName;
ReportDocument crSubReportDocument = crReportDocument.OpenSubreport(sSubreportName);
// Use a loop to go through all the tables in the main report
foreach(Table crTable in crSubReportDocument.Database.Tables)
{
// Get the TableLogOnInfo from the Table and then set the new
// ConnectionInfo values.
TableLogOnInfo crLogOnInfo = crTable.LogOnInfo;
crLogOnInfo.ConnectionInfo = crConnectionInfo;
// Apply the TableLogOnInfo
crTable.ApplyLogOnInfo(crLogOnInfo);
// Set the location of the database. This value will vary from database to
// database.
crTable.Location = "DATABASE.OWNER.TABLENAME";
}
}
}
Hope this helps!!
Regards,
Shweta
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.