[sqlite] db File Remains Open After Connection is Closed

2015-03-06 Thread Brown, Matthew
Hi Ray,



Sqlite.Net implements a connection pooling scheme. Even when your connection is 
closed, the unmanaged database handle may still be open.



After you have disposed of your connection object and are ready to do 
file-level operations, do something like this:



SQLiteConnection.ConnectionPool.ClearPool()



This should force the unmanaged connection to close if indeed there are no 
lingering open managed connections.



-- Matt Brown



On Thu, Mar 5, 2015 at 12:34 PM, RNACS - Info mailto:info at 
rnacs.com>> wrote:

"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?



[sqlite] db File Remains Open After Connection is Closed

2015-03-06 Thread GB
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
>



[sqlite] db File Remains Open After Connection is Closed

2015-03-06 Thread R.Smith
Hi Ray,

At the point when you attempt to delete the folder, if you brake your 
program there, are you able to delete it via standard windows explorer?

If not, how about closing your program, and trying directly after you 
exit your program?

Sometimes an anti-virus or other tool (such as Indexing service or such) 
might keep hold of the file or folder so you cannot delete it until it 
is done. Also, do you have permission to delete it? Is the folder near a 
Windows UAC protected path? (Such as Program Files, Windows, etc).

If you break your program and then are able to delete the file via 
explorer, none of the above is a problem, it must be your program 
holding it. When you close sqlite (calling close() in the api) it 
releases the file as soon as it is done with any current outstanding 
operations (such as a rollback or vacuum etc.) - but returns an error 
code if anything did not go smoothly. If no error code is returned (i.e 
SQLITE_OK is returned) then the files was definitely released by SQLite 
and something else is holding on to them.



On 2015-03-05 11:23 PM, RNACS - Info wrote:
> Simon,
>
> Does not help.  I put a breakpoint at the "SQLconn = Nothing" statement &
> checked the value of SQLconn.State. It was "Closed", so I continued one &
> still got the error.
>
> Ray
>
> -Original Message-
> From: sqlite-users-bounces at mailinglists.sqlite.org
> [mailto:sqlite-users-bounces at mailinglists.sqlite.org] On Behalf Of Simon
> Slavin
> Sent: Thursday, March 05, 2015 3:58 PM
> To: General Discussion of SQLite Database
> Subject: Re: [sqlite] db File Remains Open After Connection is Closed
>
>
>> On 5 Mar 2015, at 8:34pm, RNACS - Info  wrote:
>>
>> 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
> After "SQLconn.Close()", check again the state of the connection to see if
> it was successfully closed.  If not, display an error message.
>
> Simon.
> ___
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
> ___
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



[sqlite] db File Remains Open After Connection is Closed

2015-03-05 Thread Simon Slavin

On 5 Mar 2015, at 9:23pm, RNACS - Info  wrote:

> Does not help.  I put a breakpoint at the "SQLconn = Nothing" statement &
> checked the value of SQLconn.State. It was "Closed", so I continued one &
> still got the error.

Okay.  Worth checking.  I'm afraid I don't know your API well enough to suggest 
anything else.

Simon.


[sqlite] db File Remains Open After Connection is Closed

2015-03-05 Thread Simon Slavin

> On 5 Mar 2015, at 8:34pm, RNACS - Info  wrote:
> 
> 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

After "SQLconn.Close()", check again the state of the connection to see if it 
was successfully closed.  If not, display an error message.

Simon.


[sqlite] db File Remains Open After Connection is Closed

2015-03-05 Thread RNACS - Info
Simon,

Does not help.  I put a breakpoint at the "SQLconn = Nothing" statement &
checked the value of SQLconn.State. It was "Closed", so I continued one &
still got the error.

Ray

-Original Message-
From: sqlite-users-boun...@mailinglists.sqlite.org
[mailto:sqlite-users-bounces at mailinglists.sqlite.org] On Behalf Of Simon
Slavin
Sent: Thursday, March 05, 2015 3:58 PM
To: General Discussion of SQLite Database
Subject: Re: [sqlite] db File Remains Open After Connection is Closed


> On 5 Mar 2015, at 8:34pm, RNACS - Info  wrote:
> 
> 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

After "SQLconn.Close()", check again the state of the connection to see if
it was successfully closed.  If not, display an error message.

Simon.
___
sqlite-users mailing list
sqlite-users at mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



[sqlite] db File Remains Open After Connection is Closed

2015-03-05 Thread RNACS - Info
No.  Any commands will have finished before the user can get to the screen
that allows them to move the data files.

Ray Andrews

-Original Message-
From: sqlite-users-boun...@mailinglists.sqlite.org
[mailto:sqlite-users-bounces at mailinglists.sqlite.org] On Behalf Of J Decker
Sent: Thursday, March 05, 2015 3:45 PM
To: General Discussion of SQLite Database
Subject: Re: [sqlite] db File Remains Open After Connection is Closed

do you have any ... SqliteCommand's laying around that aren't finished?

On Thu, Mar 5, 2015 at 12:34 PM, RNACS - Info  wrote:

> 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
>
___
sqlite-users mailing list
sqlite-users at mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



[sqlite] db File Remains Open After Connection is Closed

2015-03-05 Thread RNACS - Info
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] db File Remains Open After Connection is Closed

2015-03-05 Thread J Decker
do you have any ... SqliteCommand's laying around that aren't finished?

On Thu, Mar 5, 2015 at 12:34 PM, RNACS - Info  wrote:

> 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
>