Passing an external ADO connection into an MTS component 
Author Message
 Passing an external ADO connection into an MTS component

Hi all,

I am experiencing the following problem: I wrote a component in VC++ that
accepts an external ADO Connection object via a property. Another method of
the component then uses this connection to open a recordset. The ASP code
looks as follows:

<%
Set MyComp = Server.CreateObject("MyProgID")
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open strConnect
MyComp.Connection = Conn
MyComp.DoSomething
%>

The implementation of MyComp.Connection is simple:

m_pConnection.Attach( piConn );

where m_pConnecton is declared as _ConnectionPtr m_pConnection;

The DoSomething method calls

  hr = m_pRecordset.CreateInstance( __uuidof( Recordset ) );
  m_pRecordset->CursorLocation = adUseClient;
  m_pRecordset->CursorType = adOpenForwardOnly;
  m_pRecordset->LockType = adLockBatchOptimistic;
  m_pRecordset->Open( CComVariant( m_bstrSQL ),
   CComVariant( (IUnknown*)m_pConnection.GetInterfacePtr() ),
   adOpenUnspecified, adLockUnspecified, adCmdText );

Now the problem: when MyComp is not under Component Services (MTS)
everythnig works fine. When I register MyComp under Component Services under
W2000, the Recordset.Open call returns the error:

"Arguments are of the wrong type, are out of acceptable range, or are in
conflict with one another."

Am I correct in thinking that my component and that ADO connection object
are now in two different worlds and they can no longer communicate?

Any pointer on how to solve this problem will be much appreciated.

Peter Persits



Mon, 13 Jan 2003 03:00:00 GMT  
 Passing an external ADO connection into an MTS component
Database connection is not valid across machines..so under MTS or out of
process it doesnot work...
for connection pooling let MTS take care of.. so create the connection
object using MTS context...i.e
call as objcontext.CreateInstanse(ADODB.Connection)


Quote:
> Hi all,

> I am experiencing the following problem: I wrote a component in VC++ that
> accepts an external ADO Connection object via a property. Another method
of
> the component then uses this connection to open a recordset. The ASP code
> looks as follows:

> <%
> Set MyComp = Server.CreateObject("MyProgID")
> Set Conn = Server.CreateObject("ADODB.Connection")
> Conn.Open strConnect
> MyComp.Connection = Conn
> MyComp.DoSomething
> %>

> The implementation of MyComp.Connection is simple:

> m_pConnection.Attach( piConn );

> where m_pConnecton is declared as _ConnectionPtr m_pConnection;

> The DoSomething method calls

>   hr = m_pRecordset.CreateInstance( __uuidof( Recordset ) );
>   m_pRecordset->CursorLocation = adUseClient;
>   m_pRecordset->CursorType = adOpenForwardOnly;
>   m_pRecordset->LockType = adLockBatchOptimistic;
>   m_pRecordset->Open( CComVariant( m_bstrSQL ),
>    CComVariant( (IUnknown*)m_pConnection.GetInterfacePtr() ),
>    adOpenUnspecified, adLockUnspecified, adCmdText );

> Now the problem: when MyComp is not under Component Services (MTS)
> everythnig works fine. When I register MyComp under Component Services
under
> W2000, the Recordset.Open call returns the error:

> "Arguments are of the wrong type, are out of acceptable range, or are in
> conflict with one another."

> Am I correct in thinking that my component and that ADO connection object
> are now in two different worlds and they can no longer communicate?

> Any pointer on how to solve this problem will be much appreciated.

> Peter Persits



Sun, 19 Jan 2003 03:00:00 GMT  
 Passing an external ADO connection into an MTS component


Quote:
> Database connection is not valid across machines..so under MTS or out of
> process it doesnot work...

Actually they're not even valid across processes as far as I know.

The reason for the syptoms the original caller was seeing was that the
un-configured/non-COM+ version was running in-proc, and once you configure
it as a COM+ component it's no longer in-proc. You don't have to cross
machine boundaries to see this problem.

Jeff



Sun, 19 Jan 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Passing and ADO.Connection object between VC and VB

2. Help: Passing an ADO Connection with DCOM

3. How to pass an ADO Connection object from a DLL to VB

4. VC6++: a Link error in a MTS component using ADO1.5

5. Is there any way to achieve multithreading inside MTS COM components

6. Failure to commit database inserts by child mts component

7. Holding a list within a transactional MTS component

8. Threading Model of MTS-based ATL components

9. Threading model for MTS components

10. Debug MTS Component in Windows 2000

11. Only 1 record added using MTS component

12. Problems using OLE DB in MTS component

 

 
Powered by phpBB® Forum Software