Close all connection on exit

kadara

New member
Joined
Mar 15, 2013
Messages
3
Programming Experience
Beginner
Hi,

I'm relative new in vb.net programming, so I have some questions.
I have an application that connects to an oracle server to retrieve some records from tables.
Everything is working well. But I would prevent some problems.
Is there a possibility to close all recordsets and the connection to the oracle server, if the computer on which the application is running, is in the LogOff/ShutDown procedure (and the application was not closed), or, for some reason the application is stop working properly (stop responding)?
 
You're trying to solve a problem that doesn't exist. If you handle your data access properly then there won't be any connection open except when you're actually performing data access. Assuming that you're using raw ADO.NET and you've installed Oracle's own provider, your code should look something like this:
VB.NET:
Using connection As New OracleConnection(connectionString)
    'Use connection here.
End Using
You don't open a connection until you actually need to use it and you close it as soon as you've finished using it. You don't ever leave connections open that aren't being used. Because of the Using statement, that connection will be closed even if an exception is thrown within the block.
 
Back
Top