Page 1 of 1

Noob : Retrieve FieldNames

Posted: 02.01.2007, 19:57
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

Posted: 03.01.2007, 11:54
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

Posted: 03.01.2007, 16:09
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

Posted: 04.01.2007, 00:16
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

Posted: 04.01.2007, 02:21
by bangfauzan
For retrieving field names you can use GetFieldNames function

ex. ZTable1.GetFieldNames(List);

regards

Posted: 04.01.2007, 22:34
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!)

Posted: 05.01.2007, 09:40
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 :)

Posted: 05.01.2007, 12:02
by swierzbicki
My Delphi isn't opened so I guess it is a TStringlist ?

Posted: 08.01.2007, 05:45
by bangfauzan
Like swiersbicki said, u can use TStingList.