ATL comp. for database access 
Author Message
 ATL comp. for database access

I'm not a C++ programmer so excuse me for asking something that may be
obvious or maybe in the wrong newsgroup.

I would like to test the performance difference between using a VB component
running under COM+ and using a thread neutral (TNA) ATL component running
under COM+ to connect to a SQL server database, execute a query and return
the resulting recordset.

Does anyone have ATL sample code that do this? Preferrably a piece that
implement IObjectControl with support for object pooling. If it use OLEDB
instead of ADO but return a RS that can be used by ADO that would also be

Thank's in advance,

Sun, 06 Jun 2004 16:11:42 GMT  
 ATL comp. for database access
Oh, and in case anyone wonder why I want to test this, it is because of this
KB article:;EN-US;q291837

Sun, 06 Jun 2004 16:25:36 GMT  
 ATL comp. for database access
Here's VB sample code for what I want to do (but in a thread neutral ATL

Implements COMSVCSLib.ObjectControl

Public Function GetReadonlyRS(ByVal strConnect As String, _
                              ByVal strSQL As String _
                             ) As ADODB.Recordset

    Dim cnConn      As ADODB.Connection
    Dim rsResult    As ADODB.Recordset

    'create and open a db connection
    Set cnConn = New ADODB.Connection
    With cnConn
        .ConnectionString = strConnect
        .CursorLocation = adUseClient
    End With

    'create a new rs, set cursor type, lock type, cursor location etc
    Set rsResult = New ADODB.Recordset
    With rsResult
        .LockType = adLockReadOnly
        .CursorType = adOpenStatic
        .CursorLocation = cnConn.CursorLocation
        Set .ActiveConnection = cnConn
    End With

    'execute the query
    rsResult.Open strSQL

    'disconnect the rs
    Set rsResult.ActiveConnection = Nothing

    'set the result to the result rs
    Set GetReadonlyRS = rsResult

    'release and cleanup the local result rs and the connection
    Set rsResult = Nothing
    Set cnConn = Nothing

    'tell COM+ we're done
End Function

Private Sub ObjectControl_Activate()
End Sub

Private Function ObjectControl_CanBePooled() As Boolean
    ObjectControl_CanBePooled = True
End Function

Private Sub ObjectControl_Deactivate()
End Sub

Sun, 06 Jun 2004 16:59:17 GMT  
 [ 3 post ] 

 Relevant Pages 

1. alt.comp.databases,comp.databases,

2. How to access Custom Database Properties of a Access 97 database programmatically

3. ATL Components for Database Access

4. Accessing database with ATL Wizard

5. ATL database access

6. Accessing database with the ATL Wizard

7. Database access using ATL COM

8. Database access from ASP via ATL COM

9. ATL & database access

10. How do you access remote databases where the database is not registed in the local ODBC

11. Emergency question on c# access remote Access Database from

12. Accessing Access 1.1 or 2.0 databases with C/C++


Powered by phpBB® Forum Software