TheVampire
Programmer
I've got an app that runs fine for a while, but eventually will start reporting "Insufficient system resources exist to complete the requested service." errors. Using process explorer shows me that certain file handles are not being closed when I use an OdbcCommand object to connect to a Paradox database.
The file handle (which shows in Process explorer as the path to the database) gets created on the ExecuteScalar command, but does not disappear after the end of the using block as I would (apparently incorrectly) expect. Is the file handle controlled by the odbc connection instead? Calling GC.Collect does not help. This code (and the odbc connection object "LDB" it refers to) is in a class which implements IDisposable and the file handles persist even after the class is disposed of. The dispose method of the class has code in it to close the odbc connection, set it to nothing and dispose of it.
Later on in the code I use the same odbc connection to insert a new record in the database, with a odbc command object and a ExecuteNonQuery() command and the same thing happens. Another file handle is added and does not go away after the command object is disposed of.
Any suggestions are appreciated
Code:
Try
Using CMD As New OdbcCommand
CMD.CommandText = "SELECT MAX (UniqueID) FROM logbase"
CMD.Connection = LDB
MyHighestID = CMD.ExecuteScalar() + 1
CMD.Connection = Nothing
End Using
Catch
...
End Try
The file handle (which shows in Process explorer as the path to the database) gets created on the ExecuteScalar command, but does not disappear after the end of the using block as I would (apparently incorrectly) expect. Is the file handle controlled by the odbc connection instead? Calling GC.Collect does not help. This code (and the odbc connection object "LDB" it refers to) is in a class which implements IDisposable and the file handles persist even after the class is disposed of. The dispose method of the class has code in it to close the odbc connection, set it to nothing and dispose of it.
Later on in the code I use the same odbc connection to insert a new record in the database, with a odbc command object and a ExecuteNonQuery() command and the same thing happens. Another file handle is added and does not go away after the command object is disposed of.
Any suggestions are appreciated