
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.