[Lazarus] TSQLQuery Error Database not assigned.

William Oliveira Ferreira bdexterholland at gmail.com
Wed Dec 26 15:53:25 CET 2012


Another point is add a transaction on your project and assign it to
sqlconnection...

At least, i never connected without a transaction ....

Em 26/12/2012 12:37, "Michael Van Canneyt" <michael at freepascal.org>
escreveu:
>
>
>
> 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
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20121226/ac3d1e55/attachment-0003.html>


More information about the Lazarus mailing list