0

I have a DLL created in Delphi XE2 that is using DB Express and TClientDataSet to display the results of a join in a DB Grid. There is a simple function to launch/show the form that is exported for use in other applications. The query is executed, and the grid populated, on FormActivate.

When I call the function to show the form from a separate Delphi XE2 application, everything runs fine - no issues that I can find.

However, when I call the same function from a separate Delphi 7 application, I get an error that that TClientDataSet can't find fields from the join.

For Example, data is returned like this:

[dbxds == TSQLDataSet
 cds == TClientDataSet]

dbxds.commandtext='select s.sfield1, s.sfield2, t.tfield1, t.tfield2 from s left join t on s.sfield1 = t.tfield1';

cds.Open;

cds.fieldByName(sfield2).visible:=false;//to hide from a dbgrid
cds.fieldByName(tfield2).visible:=false;//to hide from a dbgrid

When called from XE2, no issues. When called from Delphi 7, the last line (used to hide that field from the db grid) gives an error that:

cds: Field 'tfield2' not found 

Though the first line is fine - if I switch the order of the query so that that 't' fields are retrieved first ('from t left join s'), then I get the error on the 's' field instead.

Any thoughts on what could be causing the incompatibility?

Thanks!

TLama
  • 75,147
  • 17
  • 214
  • 392
ConBran
  • 369
  • 2
  • 15

1 Answers1

0

OK so, I noticed something odd and that put me on the path to getting the answer to this.

It just happened that, in either table, the field I was trying to access to hide was of type 'tinyint(1)'. If I tried to hide a field of type int/varchar etc, no error was thrown.

I swapped my 'tinyint(1)' fields for 'int(1)' and it works fine.

No idea why this was happening, but I'm glad I caught it and, if any one else runs into this issue, I hope that this answers their question for them too.

ConBran
  • 369
  • 2
  • 15