VB6: Problem sharing ADO connection between COM Objects (complex problem) 
Author Message
 VB6: Problem sharing ADO connection between COM Objects (complex problem)

Your application may have an object declared as ADODB.Connection, e.g.,

Public mConn as ADODB.Connection

This object can be initialized and passed wherever necessary.  If this
is what you are doing, then you will have no problem - one connection
object initialized once used generally.  

When I have seen this error, the connection object was public within the
data tier dll, and the error occurred because a second instance of the
data dll was being instantiated (wrongly).  

I am not sure what you mean that

Quote:
> another instance of the ADO object is created by the VB environment
> (because I added the ADO 2.5 to the reference list).

> Hello,

> I have one main applications that calls objects to procedure reports and
> other stuff.

> To these objects I pass the ADODB.Connection, so the object can use the
> connection from the main application (I don't want multiple connection).

> When an object is compiled it works, but when I start an object from VB to
> debug it, I get a runtime error 3001.
> I think the reason for this is when a compiled object is called, it uses the
> instance of the ADO object from the application. When my object is started
> from VB, another instance of the ADO object is created by the VB environment
> (because I added the ADO 2.5 to the reference list).

> So my conclusion: If I have two instances of ADO, I cannot pass the
> connection of the first instance to the second, and create a recordset in
> the second instance with the connection of the first object.

> Is this correct or is there a solution?

> Regards,

> Rene

> APP:
> set obj = CreateObject ( "MyObject.Class" )
> obj.Initialize gcn
> obj.RunReport

> OBJECT:
> obj.Initialize ( pcn as adodb.connection )
>   set rs = new adodb.recordset
>   rs.open <query>, pcn
>   ' pcn cannot be used here when object is started from VB
>  ' Run time error '3001' Arguments are of the wrong type etc.



Fri, 25 Apr 2003 03:00:00 GMT  
 VB6: Problem sharing ADO connection between COM Objects (complex problem)
Hello,

I have one main applications that calls objects to procedure reports and
other stuff.

To these objects I pass the ADODB.Connection, so the object can use the
connection from the main application (I don't want multiple connection).

When an object is compiled it works, but when I start an object from VB to
debug it, I get a runtime error 3001.
I think the reason for this is when a compiled object is called, it uses the
instance of the ADO object from the application. When my object is started
from VB, another instance of the ADO object is created by the VB environment
(because I added the ADO 2.5 to the reference list).

So my conclusion: If I have two instances of ADO, I cannot pass the
connection of the first instance to the second, and create a recordset in
the second instance with the connection of the first object.

Is this correct or is there a solution?

Regards,

Rene

APP:
set obj = CreateObject ( "MyObject.Class" )
obj.Initialize gcn
obj.RunReport

OBJECT:
obj.Initialize ( pcn as adodb.connection )
  set rs = new adodb.recordset
  rs.open <query>, pcn
  ' pcn cannot be used here when object is started from VB
 ' Run time error '3001' Arguments are of the wrong type etc.



Sat, 26 Apr 2003 08:36:41 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. VB6: Problem sharing ADO connection between COM Objects (complex problem)

2. Problem sharing ADO connection between COM Objects (complex problem)

3. Problem sharing ADO connection between COM Objects (complex problem)

4. Com 1 and Com 3 sharing IRQ problem

5. Can I share connection in COM object?

6. MTS Problem w/ VB6 COM Object

7. Sharing an ADO connection with an ActiveX out-process object

8. connection problem with ADO command object ......

9. problems using OpenSchema method of an ADO connection object

10. Please help!!!ADO connection object problem

11. ADO Connection Problem and Windows 2000 - multiuser problem

12. how do I declare an ADO connection for a COM object

 

 
Powered by phpBB® Forum Software