Page 1 of 1

DBGrid - multiple Table read with TZConnection, TZQuery Prob

Posted: 07.09.2009, 18:45
by wseifert
I try to use a DBGrid Object to display data from a MySQL database with 3 tables containing normalized data. So I created a test app, put TZConnection with connection information to the MySQL database, TZQuery (connection = TZConnection, SQL property = select * from tracks, album, artists where tracks.trArtistId = artists.ArtistId and tracks.AlbumId = album.AlbumId order by tracks.AlbumId), TDataSource (Dataset = TZQery) and DBGrid (Datasource = TDataSource) on a Form. Setting the TZQuery property "Active" to True a Messagebox pops up with Error "SQL Error: No Database selected". I have a TCP/IP connection to the database, so the database property in TZConnection is empty, other database properties I cannot find.
What is wrong? Any help is wellcome.

Greetings
Werner

Posted: 22.09.2009, 22:52
by mdaems
Just for the record : on 7 september I mailed this to Werner:
Werner,

I just saw your question pass by. I don't want to login to the forum now, but here's the answer :
For mysql you always have to use the database property, unless you prefix the table names in your query with the database name.
The value of 'database' is the name you use on the mysql command prompt in the 'use <database>;' command.
He replied this solved his problem.

Mark