On Wed, 26 Dec 2012, Giuliano Colla wrote:
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
Did you set
SQLQuery1.Database:=MySQLConnection1;
?
Also 'Show databases' will - to my knowlegde - not work. It is not valid SQL.
as far as I know, it's a metadata statement that is handled by the mysql
client which translates it to an API call.
Michael.
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus