[bug_fixed] GetFieldNames on ZConnection

Freature requests from users for ZeosLib's DBOs

Moderators: gto, cipto_kh, EgonHugeist, mdaems

Post Reply
User avatar
simpsomboy
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: 14.09.2005, 06:05

[bug_fixed] GetFieldNames on ZConnection

Post by simpsomboy »

Your ZeosLib DBO Version: 6.6.1
The IDE you are using: Delphi
Version (and maybe patchlevel) of the IDE: 7
The database you are using: Firebird
Version of the database: 1.5
Used protocol: firebird-1.5
[hr]Error description and post

I sugest you to put a function to get the fieldnames directly from connection
like gettablenames

somethin like this


TZConnection....

interface

Code: Select all

  public
    procedure GetFieldNames(const TablePattern: string; List: TStrings);
implementation

Code: Select all

procedure TZConnection.GetFieldNames(const TablePattern: string; List: TStrings);
var
  Metadata: IZDatabaseMetadata;
  ResultSet: IZResultSet;
begin
  CheckConnected;
  List.Clear;
  Metadata := DbcConnection.GetMetadata;
  ResultSet := Metadata.GetColumns('', '', TablePattern, '');
  while ResultSet.Next do
    List.Add(ResultSet.GetStringByName('COLUMN_NAME'));
end;

User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Hi,

I added this feature with some small modification : I included the column name pattern as a parameter. Renamed to GetColumnNames.
SVN Testing branch revision 241.

Mark
User avatar
simpsomboy
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: 14.09.2005, 06:05

Thank you

Post by simpsomboy »

Hi,

thank you for adding this code

it's very useful, and people doesn't need to patch their code anymore

Alexandre
edrobinson
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: 06.12.2006, 20:59

Post by edrobinson »

Hi,

I tried to use this method today after getting SVN 241.

The call: dbMySQL.GetColumnNames(TableName,'',qFields);
raises an exception "Column with name "Field" was not found."

Any thoughts?
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Which Mysql version?

Mark
edrobinson
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: 06.12.2006, 20:59

Post by edrobinson »

That was the problem. I was using an old MySQL dll. changed to 4.x and all is well.

Thanks for the quicl reply.
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Weird... I was talking about the server version... Apparently the dll also does something with the 'show columns' queries.

Anyway, now we know how to solve this.

Mark
Post Reply