Results 1 to 2 of 2

Thread: Opening Connection

  1. #1
    Sajid
    Guest

    Arrow Opening Connection

    Hi Everybody

    Can some one tell me where to open and close connection in Visual basic to make my application speed fast

    bye

  2. #2
    Fanatic Member Mindcrime's Avatar
    Join Date
    Jun 2001
    Location
    Peterborough, UK
    Posts
    555
    Add a BAS module. Add Public Connection Declaration
    Code:
    Public cnt As New ADODB.Connection
    In the Startup object connect to your Database, the connection should last the life time of your executable.
    Code:
    Private Sub Form_Load()
    
        Set cnt = ADODB.Connection
        cnt.ConnectionString myConnectionString
    
    End Sub
    Add connection.close to any Executable termination code you have.
    Code:
    Private Sub Form_QueryUnload (Cancel As Integer, UnloadMode As Integer)
        If UnloadMode > 0 Then
            cnt.Close  
        End If
    End Sub
    Hope that works!
    Last edited by Mindcrime; Jun 15th, 2001 at 06:18 AM.
    Mindcrime : )
    ICQ 24003332

    VB 5.0, VB 6.0 SP5, COM, DCOM, VB.NET Beta 2, Oracle 8

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width