Hi,
Is there a way in C# compact framework to ensure closing for instance database connection before exiting program? In Java this is handled by using shutdown hooks.
Regards,
Mikko
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
MikkoPosted Jan 7, 2008, 2:38 AM
Scott LyslePosted Dec 28, 2007, 5:10 PM
If your connection has class wide scope you could release it in the form dispose method; however, if you were to declare your connections within the scope of some method, you can use the using statement which will release the collection when it goes out of scope (example):
using
(SqlConnection conn = new SqlConnection(Properties.Settings.Default.ConnectionString)){