SQLitening Support Forum

Support Forums => You've got Questions? We've got Answers! => Topic started by: Skip on August 18, 2013, 12:35:28 PM

Title: Database Open questions
Post by: Skip on August 18, 2013, 12:35:28 PM
Is there a way to detect a currently opened database?

Thanks in advance -

Skip
Title: Re: Database Open questions
Post by: Rolf Brandt on August 18, 2013, 03:35:26 PM
From the Help file:

slIsOpen () Long
Returns %TRUE if there is a database open.

Additionally:

slGetDatabaseAndFileNames  () String
Returns a list of database and file names that are currently opened and attached.  The name entries are returned as a delimited text string which is $NUL separated.  Each entry contains two elements, a database name and a file name. The two elements are separated by the vertical bar (|) character. The first entry is always the Main database from the slOpen command.  The second entry will be the Temp database, but only if there are temporary tables currently created.  The rest of the entries, if any, will be the attached databases.  There are no file names assigned to temporary tables nor temporary databases. Will return an empty string if there is no open database.

These functions of course will detect only if they are opened by your program, not by another program.

Rolf
Title: Re: Database Open questions
Post by: Skip on August 18, 2013, 04:10:49 PM
Rolf -

Thanks much for the reply!

I especially liked the additional info you responded with.  Since slIsOpen() doesn't allow one to
ask which database is open, I'll probably want to also explore your 2nd method.

Skip