2

I have Delphi 2005 code that I use to retrieve database table field names.
It works with no problems on 32-bit machines (Windows XP, Windows Vista, Windows 7).

However it does not return any field names when run on a 64 bit machine (Windows Vista or Windows 7).

The code looks like this:

uses  Db, SQLExpr;  

procedure TForm1.ShowFieldNames(SQLConnection: TSQLConnection;  
                                FieldNames: TStringList);  
  var FieldIndex: Integer;  
begin  
  SQLConnection.GetFieldNames('TABLENAME', FieldNames);  
  ListBox.Items.Add('Field Count = ' + IntToStr(FieldNames.Count));  
  for FieldIndex:=0 to FieldNames.Count - 1 do  
    ListBox.Items.Add('FieldName = ' + FieldNames[FieldIndex]);  
  end;  

On 32-bit machines, this shows a non-zero count, and list the field names, on a 64 bit machine, this displays “Field Count = 0”

When I recompile with Delphi 2006 or Delphi 2007, the problem goes away.

(I'm using Firebird 2.5)

I want to fix this without having to upgrade the program to a later version of Delphi.

I’d also like to understand why the problem is occurring – why is the program behaving differently on 64-bit Windows.

Can you give me any advice please.

urtlet
  • 153
  • 2
  • 10
  • 1
    Sounds like a bug in D2005 specifically. (Which wouldn't surprise me; there were a lot of bugs in D2005.) I've gotta ask, if you've got D2006 and D2007 available, why do you not want to update? There aren't any major compatibility issues from 2005->2007 that I'm aware of... – Mason Wheeler Aug 31 '11 at 05:06
  • It might be a bug in D2005, but I'm puzzled why it only occurs on 64-bit machines. The main reason not to upgrade is that my client doesn't have licences for D2006 and D2007 and they want to be able to maintain the code. I think there are also some issues with third party libraries. I am going to try pulling the field names out of RDB$RELATION_FIELDS. – urtlet Aug 31 '11 at 05:29
  • Do you always connect to the same FireBird server, ie the only thing what changes is the compiled exe (using Delphi 2005 vs Delphi 2006) and client OS (32bit Win vs 64bitWin)? – ain Aug 31 '11 at 07:54
  • I've installed the same version of Firebird (32-bit client and 32-bit server) on a new 64 bit machine and on a Windows-7 32-bit VM. The code has worked on many 32-bit machines (mostly running Windows XP and Vista), and failed on at least 4 64-bit machines (running Vista and Windows 7) – urtlet Aug 31 '11 at 08:16

1 Answers1

1

Using a query:

SELECT RDB$FIELD_NAME FROM RDB$RELATION_FIELDS WHERE RDB$RELATION_NAME='TABLENAME';  

then trimming the results returned gives me the field names, and it does work on a 64-bit machine.

This doesn't explain why the program is working differently when run on a 64-bit machine, but it does give me a workable solution.

urtlet
  • 153
  • 2
  • 10