• Welcome to SQLitening Support Forum.
 

News:

Welcome to the SQLitening support forums!

Main Menu

Opposite of slAttach

Started by The Tramp, November 06, 2023, 07:06:38 PM

Previous topic - Next topic

The Tramp

Once I attached a database to the main one, how do I detach it?

cj

I have read closing a SQLite database closes attached databases.
Searched forum and source code and can't find anything on detaching a database.

Paul Squires

I haven't used SQLitening in 10 years but maybe something like the following would work:

slExe "DETACH DATABASE '" + database_name + "';"
Paul Squires <br />http://www.planetsquires.com<br />support@planetsquires.com

cj

#3
Thanks Paul!
Testing code by running multiple times and no problem.
#INCLUDE ONCE "sqlitening.inc"

FUNCTION PBMAIN AS LONG
LOCAL x AS LONG
slSetProcessMods "E2"
FOR x = 1 TO 3
  slOpen  ":memory:"
  slAttach "sample.db3","paul"
  ? slSelStr("select price from parts limit 1") '3365
  slexe "DETACH DATABASE paul"
  ? slSelStr("select price from parts limit 1") 'no such table: parts
  slclose
NEXT
END FUNCTION