Search code examples
delphicrystal-reports

Crystal XI Rel2 RDC Parameter Passing


I have the following setup:

  • Delphi 5 Enterprise Update 1 Crystal
  • Reports Developer XI Rel2 (RDC 11.5)

After long hours of trial&error I can now set the logon stuff as asked earlier but when I try to set crystal parameters by code - it does not work and I get an empty report.

I've written a small app for testing (here's just a snippet):

for i:=1 to FParamFldDefs.Count do begin

   FParFldDef := FParamFldDefs.Item[i];
   FParFldDef.ClearCurrentValueAndRange;

   if ParFieldName = 'User' then
      FParFldDef.AddCurrentValue('hugo')
   else if ParFieldName = '@P_Date' then
      FParFldDef.AddCurrentValue('2009.06.30')

   if FParFldDef.IsDefaultValueSet then
       ShowMessage('DefaultValue: ' + FparFldDef.GetNthDefaultValue(1));
       //--> on loop 1 i=1 this does not show up because IsDefalutValueSet = FALSE
       //--> on lopp 2 i=2 this does show '2009.06.30'
   if FParFldDef.IsCurrentValueSet then
       ShowMessage('CurrentValue: ' + FparFldDef.GetNthCurrentValue(1));
       //--> on loop 1 i=1 this does show 'hugo'
       //--> on lopp 2 i=2 this does not show because IsCurrentValueSet = False

end;

ShowMessage(FldDef.SQLQueryString); //this shows all
                                    //stored procedure parameters empty

Now I've managed to have the CurrentValues set (had to save the report in question with version 11 - it was version 9 before) because IsCurrentValueSet returns True but when I try to read the SQLQueryString I can see that all SP parameters are NULL. Any Ideas on that?


Solution

  • I've seen the light! If someone like me ever gets forced to deal with Delphi 5 and Crystal XI RDC - here's what I've done:

    Prerequisites:

    • you have tons of old Crystal Reports Version < 11.5
    • you still have to use old Delphi 5 applications

    Firs of all, you have to:

    1. Install Crystal Reporst Developer XI Rel2 (the last one with RDC support and don't worry, it can be installed in parallel to your existing Crystal Reports Version (in my case it was Version 6)
    2. Import Type Libraries in Delphi (craxdrt.dll + CRViewer.dll)
    3. Open the report in question with Crystal Reports XI and save it as version XI
    4. Change any Database Connection to OLEDB

    After you've done that you can use Joseph Styons wrapper class and you're just fine. If you too have a report which gets it's data from a SQL Stored Procedure just set those parameters (their names start with an "@") like any other Crystal Parameter.

    That's it, I'll hope this is usefull to somebody.

    Now I'm off for some beer!

    Cheers, Reinhard