Please also note that setting an object to 'nothing' does _not_ dispose 
it! This was the case back in the VB6 days, but in the .NET world you 
need to enclose all objects implementing 'IDisposable' in a 'using' 
block or call Dispose() explicitly on all your objects to properly 
release any resources. If you don't do so, Dispose() will be called on 
behalf of  the Garbage Collector, which may well never happen during the 
runtime of your code.

GB

RNACS - Info schrieb am 05.03.2015 um 21:34:
> I have a program written in Visual Basic .NET.
>
> One of the functions of the program is to move all of the program's data,
> including a SQLite database to a different folder.
>
> The program is a 32-bit application using System.Data.SQLite.dll.
>
> I am having a problem that after I copy the data to the new folder, the
> program fails when I try to delete the old folder.  The error message says
> that the folder cannot be deleted because the SQLite database file is in use
> by another process.
>
> The code I am using is:
>
>          ' Close license database connection
>          If Not IsNothing(SQLconn) Then
>              If SQLconn.State <> ConnectionState.Closed Then
>                  SQLconn.Close()
>              End If
>              SQLconn = Nothing
>          End If
>
>          ' Move data files
>        '\\\\\ code to move files goes here
>
>          ' Delete old directory
>        Directory.Delete(strOldLocation,
> FileIO.DeleteDirectoryOption.DeleteAllContents)
>
> The error occurs when I try to execute the "Directory.Delete" statement.
>
> "SQLconn" is a SQLiteConnection to my database file.  Once the connection is
> closed & disposed of, what still has the .db file still open?  How do I
> close the file so I can delete it?
>
> Thank you for any assistance.
>
> Ray Andrews
>
>
>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>

Reply via email to