Page 1 of 1
How to get the Columntypes of a tabel
Posted: 14.04.2011, 09:57
by mikesmurph
Hi,
is there a way to get the Columntypes of a Table?
I need the Types like (varchar, int, ...) of column. Can anyone help me?
Thanks
Michael
Posted: 14.04.2011, 10:12
by jeremicm
ZQuery.Fields[].DataType should do it...
Posted: 14.04.2011, 10:43
by mikesmurph
Hi jeremicm,
thanks for your help, but i need the SQL-Types not the Delphi-Types.
For Example: My Table have a Column FaxNumber an the SQL-Datatyp is Char.
Michael
Posted: 14.04.2011, 11:13
by Dali
I don't understand why do you need that but, correct me if I'm wrong, as every database manager uses its own SQL dialect, and Zeos tries to keep separate both kind of types, providing public access only for those you'll actually need to write an application (which are the Delphi ones), I'm afraid that the easiest way of doing that is accessing the metadata of the underlying database directly using SQL code... Which is, of course, not portable.
Posted: 15.04.2011, 09:23
by jeremicm
You can always do SHOW CREATE TABLE tblname (for mysql, or similar for database you use) and parse result for column you need...