Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread Checking for created database
Sat, Sep 8 2012 9:51 PMPermanent Link

Colin Wood

VirtualTec P/L

Hi Guys,
Could someone please tell me what is the best way to check for an existing database?
When I use
     MainFrm.FDASession1.Execute('CREATE DATABASE "FDADb" PATH ' +
                                 Quote('c:\fda\data') +
                                ' DESCRIPTION ''FDA Database''');
it sometimes already exists, and I get the warning message.
Is there something similar to checking for tables by using
     if (Execute('Select * From Information.Tables '+ 'Where Name='+Engine.QuotedSQLStr('Prefs'))=1) then...
but for the database instead, or should some code be placed in the "before connect" of the database?
Thanks
Colin
Sat, Sep 8 2012 10:49 PMPermanent Link

Raul

Team Elevate Team Elevate

You can query the configuration database. something like :

SELECT * from Configuration.Databases where Name='<your db name>'

If this returns data then db exists

Raul

On 9/8/2012 9:51 PM, Colin Wood wrote:
> Hi Guys,
> Could someone please tell me what is the best way to check for an existing database?
Sun, Sep 9 2012 3:23 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Colin


And if you follow up Raul's suggestion with a FileExists tests for the catalog file it will tell you if the database really exists on the harddrive. Only needed if you're paranoid or someone messes with your system Smiley


Roy Lambert [Team Elevate]
Sun, Sep 9 2012 3:31 AMPermanent Link

Colin Wood

VirtualTec P/L

Thanks Raul and Roy.  Paranoia comes naturally! Smile
Image