how do i check if database exist or not with mydac
Posted: Wed 24 Feb 2016 20:38
in my application if there is database not exist application raise exception because data base not exist how do i check if data base exist ?
Discussion forums for open issues and questions concerning database tools, data access components and developer tools from Devart
https://forums.devart.com/
Code: Select all
MyConnection.Database := 'DBName';
try
MyConnection.Connect;
ShowMessage('DBName exists.');
except
on E : Exception do
if Pos('Unknown database', E.Message) <> 0 then
begin
ShowMessage('DBName not exists.');
end;
end;Code: Select all
procedure TForm.ButtonClick(Sender: TObject);
var
Databases: TStringList;
begin
MyConnection.Database := 'mysql';
Databases := TstringList.Create;
try
MyConnection.GetDatabaseNames(Databases);
if Databases.IndexOf('DBName') <> -1 then
ShowMessage('DBName exists.')
else
ShowMessage('DBName not exists.');
finally
Databases.Free;
end;
end;