Query "Show databases" create exception


2004-08-10 03:45:34 PM
delphi202
Hi all.
I need to be able to create a list of all existing databases
[mysql-server (v. 3.23), Delphi 6].
I make a connection with TSQLConnection:
FSQLConnection := TSQLConnection.Create(nil);
FSQLConnection.ConnectionName := 'MSConnection';
FSQLConnection.DriverName := 'MYSQL';
FSQLConnection.GetDriverFunc := 'getSQLDriverMYSQL';
FSQLConnection.KeepConnection := false;
FSQLConnection.LibraryName := 'dbexpmysql.dll';
FSQLConnection.LoginPrompt := false;
FSQLConnection.LoadParamsOnConnect := false;
FSQLConnection.VendorLib := 'LIBMYSQL.dll';
FSQLConnection.Params.Add('HostName='+host);
FSQLConnection.Params.Add('User_Name='+user);
FSQLConnection.Params.Add('Password='+password);
// I use database = mysql as default, since I know it exists
FSQLConnection.Params.Add('Database=mysql')
Then I create a query and try to execute it:
with TempSQLQuery do try
SQL.Clear;
s := 'SHOW DATABASES';
SQL.Add(s);
Open; // Exception ->"you have an error in your
// sql syntax near "%s" at Line 1
first;
while not eof do begin
ADBList.Add(Fields.fieldbyname('Database').AsString);
next;
end;
finally
free;
ADBList.Free;
end;
This is the code for TempSQLQuery used above
function TFrameWizardDatabase.TempSQLQuery: TSQLQuery;
begin
result := nil;
try
result := TSQLQuery.Create(nil);
result.SQLConnection := FSQLConnection;
except
on e:exception do begin
ShowMessage(e.Message);
end;
end;
end;
The code works if I use S:="SELECT * FROM database1" or any other
SELECT statement.
Does anyone have an idea, as to what I am doing wrong??
Thanx in advance
Dortique