title: Error using SQLite ATTACH - DETACH in Delphi
body: <p>I experience a, for me unsolvable, problem with ATTACH and DETACH in SQLite, using Delphi (Firedac).</p>
  
  <p>I have one database file connected and attach a second one with:</p>
  
  <pre><code>FDConnection1.ExecSQL('ATTACH DATABASE "' + Import_DB_filename + '" AS IMPORTDB;');
  </code></pre>
  
  <p>Therein, the variable 'Import_DB_filename' contains the full path and filename of the database file.</p>
  
  <p>This works OK and I can access both databases within the connection through the FireDac queries, and can do my coding without problems. 
  However, things go wrong upon detaching:</p>
  
  <pre><code>FDConnection1.ExecSQL('DETACH DATABASE IMPORTDB;');
  </code></pre>
  
  <p>In debugging mode, I always get the error:</p>
  
  <blockquote>
    <p>Debugger Exception Notification<br />
      E Project My_Program.EXE raised exception class $C0000005 with message    'access violation at 0x00405d7b: read of address 0x00000000'.</p>
  </blockquote>
  
  <p>Apparently something goes wrong with the memory assignments, since the debugger stops in a (assembly) function <code>SysFreeMem(P:Pointer): Integer;</code> in <code>GETMEM.INC</code>.</p>
  
  <p>Whatever I try, the error persists and associates a memory leak that eventually leads to a crash of the compiler (Delphi Seattle Enterprise).</p>
  
  <p>Even attaching and subsequent detaching of the database without passing any code results in the same error. </p>
  
  <p>(FDconnection:  locking mode = lmNormal; 
                  JournalMode  = jmOff or jmWALL or jmdelete)</p>
  
  <p>I do hope that you can help me out on this lasting problem.</p>