|
-
May 4th, 2000, 04:16 PM
#1
Thread Starter
New Member
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
-
May 4th, 2000, 04:34 PM
#2
Lively Member
If you really want, you can do this:
Function Test(a as ADODB.connection)
end function
Call Test oConn
-
May 4th, 2000, 06:29 PM
#3
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|