Showing results for 
Search instead for 
Did you mean: 

How to remove sub-report data links from the sdk

0 Kudos

I use the crystal report SDK to generate pdf files. We're currently trying to use dataSet as a data source. Everything works but the subReports are empty after export. We modified the rpt: -> database expert -> links -> remove link and save the subReport and it works. The idea would be to reproduce the same thing from the SDK. I.e. go from a query with “INNER JOIN” to just “SELECT...”.

Acutal : 

FROM `AdditionalFees__` `AdditionalFees__` INNER JOIN `GdrFields` `GdrFields` ON `AdditionalFees__`.`parentKey`=`GdrFields`.`key`

Want this 
SELECT `language`.`TaxSummaryNetAmount`, `language`.`TaxSummaryVAT`, `language`.`TaxSummaryTaxAmount`
FROM `language` `language`

View Entire Topic
Active Contributor
0 Kudos

Hi Again,

OK there's a few different ways to handle this but first let me clarify what is NOT possible.

I see now what you are attempting to do, sorry I'm retired now so I didn't recognize what you are actually attempting to do...

You cannot modify the SQL in the Report or subreport, CR hasn't be able to do this for quite some time, it used to be able to but it caused all sorts of problems so the function was removed. To many objects to make changes to for complex reports with complex data structures. So what Product did was add the Command Object, basically add your own SQL and then you can edit it as required, as long as it didn't break the report.

And before you ask there is no way to change the data source from tables to a command object, well maybe bit to complex, someone may be able to describe how to, without your data source it's too much to explain.

CR keeps the Data structure embedded in the RPT file so it's not simple to alter, CR hates it when the structure changes, SDK assumes the report info is 100% correct.

So if you look in my test app for

SetData_Click(object sender, EventArgs e)

you can see part of your issue may be multiple Tables in your DataSet, so you may need to adjust your code accordingly. But you won't be able to change the SQL.

Look at this routine also:

DataSet1_Click(object sender, EventArgs e)

And this routine may be of help also:

ReplaceConnection_Click(object sender, EventArgs e)

NOTE: to change any object using RAS you first must Clone() the object collection, delete the existing, then make your change to the cloned collection and the apply the change to the report.

To change the SQL in a Command it's simple, search for "Command" in my test all, you'll see I get it in the may routine, you can then change the SQL, I don't have any examples but it is easy to do, I just don't recall the code...

SO to sum up:

You can't remove the JOIN from the SQL, sorry I should have caught this sooner...

TO be able to you will need to edit the Subreport, In CR Designer you can export the subreport, make the changes to it and then add the subreport back into the main report, NO SDK function to this, must be done in the Report Designer. SDK has no function to export the subreport only.

Now you can copy the SQL in the subreport and set location to a Command and paste in the SQL.

It's not clear though, if your subreport is using a DataSet then CR should not have the JOIN in it's subreport SQL??? If you look at my routine I use standard SQL to populate the DataSet, so this should be what you need to do also.

But since I don't have your report or Dataset I can't be sure exactly what you are doing...

Hope that helps