Hi Everybody
Can some one tell me where to open and close connection in Visual basic to make my application speed fast
bye
Printable View
Hi Everybody
Can some one tell me where to open and close connection in Visual basic to make my application speed fast
bye
Add a BAS module. Add Public Connection Declaration
In the Startup object connect to your Database, the connection should last the life time of your executable.Code:Public cnt As New ADODB.Connection
Add connection.close to any Executable termination code you have.Code:Private Sub Form_Load()
Set cnt = ADODB.Connection
cnt.ConnectionString myConnectionString
End Sub
Hope that works!Code:Private Sub Form_QueryUnload (Cancel As Integer, UnloadMode As Integer)
If UnloadMode > 0 Then
cnt.Close
End If
End Sub