mysql TZTable.Fieldcount always 0

In this forum we will discuss things relating the ZEOSLib 6.6.x stable versions

Moderators: gto, EgonHugeist

Post Reply
pomalo
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 19.11.2008, 20:36

mysql TZTable.Fieldcount always 0

Post by pomalo »

hi

i try to find the number of field in a Mysql table. the table has 10 fields.

using

Code: Select all

tblDetail.FieldCount;
return always 0

i have try to use a TZQuery in a function returning an integer

Code: Select all

Query.SQL.ADD('SELECT COUNT(*) as total FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = "' + mytable +'" AND TABLE_SCHEMA = "' + myDatabase + '";';  
Query.ExecSQL;
Result := Query.FieldByName('total').asInteger;

an exception occur saying
Query: Field not found "total"
Sending the query with the same user end password to the mysql utility return the good field count (10)

i use Lazarus 0.9.30 with FPC 2.4.2 on windows 7 and mysql 5.5

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

Post by mdaems »

Not sure if that fixes your problem, but you should use Open instead of Execsql to get a resultset. Execsql is made for executing updates, deletes, inserts or alters. Not for returning resultsets.

Mark
Image
Post Reply