on ‎2021 Mar 04 12:04 PM
Report with Command object:

Debugger Output:

Problem:
We are using CR .NET dll version 13.0.29.
We have a Report with command object, and we can get the SQL Query(CommandText) using following code ( Code_block_1). It works fine for the main report. This same report also contains subreport which contain Command Object, but we are not able to get the SQL Query(CommandText) for the subreport using below code(Code_block_1).
But As per the debugger output (please refer the attached image), we are able to see the CommandText. To get the commandtext for the Subreport, we are using code_block_2. And we could get the commandtext for subreport. Is it a right approach to get the commandtext for the subreport using code_block_2. Please confirm.
Requirement:
Is it a right approach to get the commandtext for the subreport using code_block_2. Please confirm.
Pseudo Code:
Code_block_1:
CrystalDecisions.ReportAppServer.DataDefModel.CommandTable
boCommandTable;boCommandTable =
(CrystalDecisions.ReportAppServer.DataDefModel.CommandTable)reportDoc.ReportClientDocument.Database.Tables[0];
ReportSQLQuery = boCommandTable.CommandText;
Code_block_2:
PropertyInfo pi =
subReportDocument.Database.Tables.GetType().GetProperty("RasTables",
BindingFlags.NonPublic | BindingFlags.Instance);
ReportSQLQuery = ((dynamic)pi.GetValue(subReportDocument.Database.Tables, pi.GetIndexParameters()))[0].CommandText;
Thanks,
Samson
Request clarification before answering.
Yes it is...
For more info here's the link to my CR for VS Wiki:
https://wiki.scn.sap.com/wiki/display/BOBJ/Crystal+Reports%2C+Developer+for+Visual+Studio+Downloads
Note: SP 30 is available now and you should upgrade.
On that page is a Parameter test app with log on code that has more info about subreports.
Don
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This particular piece of code raises an exception here:
if (pi == null) return;
var ReportSQLQuery = ((dynamic)pi.GetValue(doc.Database.Tables, pi.GetIndexParameters()))[0]
.CommandText;Exception is:So it would seem the example needs review? I just need to document the Command object sql - nothing more... The code at the link seems to be more worried about parameters and what not...
That being said, your contributions here, Don, are legendary and very helpful!! Thank you.
| User | Count |
|---|---|
| 8 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.