cancel
Showing results for 
Search instead for 
Did you mean: 

'System._ComObject' does not contain a definition for 'CommandText' for subreport object

0 Kudos

Problem : Subreport object does not have commandText(SQLQuery) We are using CrystalReport .NetSdk v13, and ServicePack30 and used in 32bit application.

Initially this superb.rpt has multiple tables and we converted into single command based table in 2020CR designer and we are able to see the subreport data in design mode in CR Designer 2020.But when we integrate same rpt file in our 32bit application it is throwing 'System._ComObject' does not contain a definition for 'CommandText' for subreport object. Could you please help on this

Below is the code snippet:
 		ReportSQLQuery = string.Empty;
                if (HasCommandObject())// To check whether it has command table
                {
                    if (!ReportDocument.IsSubreport)// MainReport objectcommandText
                    {
                        CrystalDecisions.ReportAppServer.DataDefModel.CommandTable boCommandTable;
                        boCommandTable = (CrystalDecisions.ReportAppServer.DataDefModel.CommandTable)ReportDocument.ReportClientDocument.Database.Tables[0];
                        ReportSQLQuery = boCommandTable.CommandText;
                    }
                    else //SubReport Object commandText
                    {
                        PropertyInfo pi = ReportDocument.Database.Tables.GetType().GetProperty("RasTables", BindingFlags.NonPublic | BindingFlags.Instance);
                        ReportSQLQuery = ((dynamic)pi.GetValue(ReportDocument.Database.Tables, pi.GetIndexParameters()))[0].CommandText;
                    }
}

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi Mahesh,

I fixed my Parameter test app that now gets subreport Command SQL.

Search for this KBA: 2281780 - How To: Parameters in Crystal Reports for Visual Studio .NET

And wiki here:

https://wiki.scn.sap.com/wiki/display/BOBJ/Crystal+Reports%2C+Developer+for+Visual+Studio+Downloads

Answers (1)

Answers (1)

0 Kudos

Where are you opening the subreport object to get it's Command?