Best practice with a Connection object in VB 2005
Posted on 2007-03-29
In VB6, we used to open a Public Connection object in Sub Main() and the Connection object used to be open till the application was running.
In VB 2005, I am declaring a connection object in a Module like this:
Public cnMain As New Data.SqlClient.SqlConnection("Data Source=localhost;Initial Catalog=dbAccounts;Integrated Security=True")
and in the Application_startup event I am opening the connection object which remains open througout the application.
My question is that what I am doing is the optimized way of doing it or is there some other better way to do this?