开发者

TSQLConnection.GetFieldNames not working on 64-bit machine

开发者 https://www.devze.com 2023-04-01 02:12 出处:网络
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).

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 = ' + IntTo开发者_如何学编程Str(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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号