Results 1 to 3 of 3

Thread: adodb.connection

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2000
    Location
    Dubai, U A E
    Posts
    3

    Question

    Can anyone help me with this one.

    What i am trying to do is to minimize the number of connecitons to a database in a project, and my project is devided into different dlls. The main integrated form and the fuction/procedures would call the needed funcitons/procedures inside the relevant dlls. The problem is : i want to use only one connection to a database for this project, so, for that i need to pass the connection object to the called function/procedure inside the dll.

    So, the question is "How do i pass the connection object into a method in a class of a dll?

    Any help in the above subject, would be very much appreciated.
    Thanks & Rgds.
    crocogator

  2. #2
    Lively Member
    Join Date
    Aug 1999
    Posts
    89
    If you really want, you can do this:

    Function Test(a as ADODB.connection)
    end function

    Call Test oConn

  3. #3
    Lively Member
    Join Date
    May 1999
    Location
    belgium
    Posts
    74

    Smile

    in all you dll's, you put 2 public properties and 1 private declaration:

    private mo_cnn as ADODB.Connection

    Public Property Let ao_cnn(ByVal value As ADODB.Connection)
    Set mo_cnn = value
    End Property
    Public Property Get ao_cnn() As ADODB.Connection
    Set ao_cnn = mo_cnn
    End Property

    In your main form, you must open and close your connection and then give your connection to the other dll'. Do that this way:

    'Opens the connection if the connection is closed
    If mo_cnn.State = adStateClosed Then
    mo_cnn.ConnectionString = "connectionstring"
    mo_cnn.Open
    End If

    objectname.ao_cnn = mo_cnn
    call your method in your dll

    'Closes the connection if the connection is open
    If mo_cnn.State = adStateOpen Then
    mo_cnn.Close
    End If

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