[Lazarus] TSQLQuery Error Database not assigned.

Giuliano Colla giuliano.colla at fastwebnet.it
Wed Dec 26 15:02:14 CET 2012


I'm trying to familiarize with MySql components, using mysql 5.1.
I downloaded the TryMySql example linked from the Wiki page, I've 
changed  TMySQL50Connection to TMySQL51Connection, and set in SQLQuery 
ParseSQL=False and ReadOnly=true, as suggested, but when I try to run 
it, the "connect to server" fails with the error "Database not assigned!".
The code I'm using is:

   MySQLConnection1.HostName := HostEdit.Text;
   MySQLConnection1.UserName := UserEdit.Text;
   MySQLConnection1.Password := PasswdEdit.Text;
   MySQLConnection1.DatabaseName := 'mysql'; // MySQL is allways there!
   ShowString('Opening a connection to server: ' + HostEdit.Text);
   MySQLConnection1.Open;

   // First lets get a list of available databases.
   if MySQLConnection1.Connected then begin
     ShowString('Connected to server: ' + HostEdit.Text);
     ShowString('Retreiving list of available databases.');
     SQLQuery1.SQL.Text := 'show databases';
     SQLQuery1.Open; <==== Fails here


This occurs both with Lazarus 1.02 and with Lazarus svn (rev.39655), and 
fpc 2.6.0, in Linux (FC14) environment.
Useless to say that mysql from command line, with identical parameters 
works as expected.
Am I doing something wrong, should I use fpc 2.6.1, set some extra 
parameter, or what?

Any help is welcome!

Giuliano







More information about the Lazarus mailing list