Noob : Retrieve FieldNames

Forum related to version 6.5.1 (alpha) and 6.6.x (beta) of ZeosLib's DBOs

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
kobalt
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 02.01.2007, 19:42

Noob : Retrieve FieldNames

Post by kobalt »

Hi,

first off a little rant on this project, the project is gread I am happy I don't have to use this whole ODBC connection stuff, that you would normally have to go through to get connected to a database. Well anyway's I was hoping for a little bit more documentation on Zeos, I doesn't seem to find explanations about how to properly use the Lib. I would be more than happy with a simple generated Documentation from the source code's comments, but I guess there is nothing like Javadoc for delphi/pascal.

Anyway my big first ?

How do I get zeoslib to retrieve the Fieldnames, from the current selected table??? Do you have to use ZMetadata and if yes how do I use this to get let say Strings out of it.




Thx in advance, I am not really used to Delphi, first time to try it out, cause a friend of mine had some problems I though I would take a look into it to help him out a bit. Thx a lot though for replies :)

Cya
btrewern
Expert Boarder
Expert Boarder
Posts: 193
Joined: 06.10.2005, 18:51

Post by btrewern »

If you are using a ZTable then:

var
i: Integer;
begin
for i := 0 to Ztable1.FieldCount - 1 do
begin
...... Do stuff here with your fields ........
...... ZTable1.Fields.FieldName ......
end;
end;

Hope this helps.

BTW ZeosLib works in a very similar way to other TDataset descendents. If you look in the Delphi help for TTable or TQuery you should be able to relate most of that to ZeosLib.

Regards,

Ben
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 kobalt,

I fully agree when you say we need some more documentation.
Michael started with some documentation effort the way you proposed, but it's not complete. Please have a look here.

The way I learned how to use Zeoslib the one proposed by Ben : Just look in the Delphi help. There documentation has been written by professionals. There's plenty of examples.

Some additional advise: use a ZQuery instead of a ZTable unless you really need all columns and all rows of a table. (Just for performance.)

Mark
kobalt
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 02.01.2007, 19:42

Post by kobalt »

Thx a lot guys, I 'll take your advise.

Some additional advise: use a ZQuery instead of a ZTable unless you really need all columns and all rows of a table. (Just for performance.)
That's exactly what I am trying to do atm. Just wanted to List all Entries from a table (Client sortatable) to a TStringGrid. So I guess using ZTable would be the easiest and best way then. I 'll have a look into that.


Thanks a lot :)



*whispers

A few more examples, would be welcome. Just put them as download on the portal, so everybody can have a look into them, doesn't matter if they are crappy .... just to get the idea, cause I think there are more people like me out there.

That's no rant at all....just an advice to get the forums cleaner with noob question like mine.

I've had a look into that ongoing documentation project. It's good to have an overlook on all functions and properties. But as you already said it's not complete.

Keep up the good work!!!


L8tr
bangfauzan
Senior Boarder
Senior Boarder
Posts: 50
Joined: 31.08.2006, 10:41
Contact:

Post by bangfauzan »

For retrieving field names you can use GetFieldNames function

ex. ZTable1.GetFieldNames(List);

regards
zippo
Silver Boarder
Silver Boarder
Posts: 322
Joined: 12.10.2005, 18:01
Location: Slovenia

Post by zippo »

One more trick: If you want, you can use table fieldnames to get what you need. Example:

Query1.FieldByName('FIRST_NAME').AsString := 'Hohoho';

Ah, and finally: Have a nice and successfull 2007!! (This is dedicated to all!)
kobalt
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 02.01.2007, 19:42

Post by kobalt »

bangfauzan wrote:For retrieving field names you can use GetFieldNames function

ex. ZTable1.GetFieldNames(List);

regards

Hi, just wanted to ask which type of List I should use?


Thx for these many replies .. really happy about that. I slowly get into zeos :) .... makes live really easier after all :)
swierzbicki
Fresh Boarder
Fresh Boarder
Posts: 20
Joined: 24.08.2005, 08:50

Post by swierzbicki »

My Delphi isn't opened so I guess it is a TStringlist ?
bangfauzan
Senior Boarder
Senior Boarder
Posts: 50
Joined: 31.08.2006, 10:41
Contact:

Post by bangfauzan »

Like swiersbicki said, u can use TStingList.
Post Reply