Please start any new threads on our new 
    site at https://forums.sqlteam.com.  We've got lots of great SQL Server
    experts to answer whatever question you can come up with.
    
        | 
                
                    | 
                            
                                | Author | Topic |  
                                    | ccavStarting Member
 
 
                                        3 Posts | 
                                            
                                            |  Posted - 2009-05-07 : 15:00:29 
 |  
                                            | Strange problem.  Have a function that returns @@trancount.  The following code results in trancount going to 0.Using ADODB library in VBA/access app.  ocmd is ADODB.CommandoConn is custom class wrapping ADODB.Connection and exposes the connection at <object>.connection and returns @@TRANCOUNT at <object>.trancount.  oRS is new adodb.recordset.  oConn was previously instantiated and set to .Mode = adModeReadWrite, .CommandTimeOut = 0, and .IsolationLevel = adXactReadCommittedbackend is sql server 2005Transactions are named.  Xact management is in application, but this is a single user app just used to import some data, so not an issue.tranindex = oconn.trancount  <- results in 2  1 outer/1 inner xactSET ocmd.activeconnection = oconn.connectionocmd.commandtext = "dbo.blah"ocmd.commandtype = adCmdTableoRS.cursorlocation = adUseServeroRS.cursortype = adOpenDynamicoRS.LockType = adLockBatchOptimisticoRS.Open ocmd                  <- recordset opens and records from previously committed inner xact are exposed.tranindex = oConn.TranCount  <- returns 0The ADODB.recordset open has somehow set @@TRANCOUNT to zero.  Looking at oRS.commandtext it's select * from dbo.blah...Will a SELECT statement set @@TRANCOUNT to zero while in a transaction?  Or is there a bug in ADO recordset open?  This doesn't happen on adodb.recordset.execute, @@TRANCOUNT is maintained normally.Any help? |  |  
                                    | ccavStarting Member
 
 
                                    3 Posts | 
                                        
                                          |  Posted - 2009-05-07 : 15:10:24 
 |  
                                          | Correction in last statement.  Doesn't happen on oconn.connection.execute |  
                                          |  |  |  
                                    | ccavStarting Member
 
 
                                    3 Posts | 
                                        
                                          |  Posted - 2009-05-07 : 15:36:17 
 |  
                                          | Solved...  found the bug.Changing ado connection from adUseClient to adUseServer was causing it.  Must reset the ado connection when u do that.  I guess comingling recordsets client/server will need two different connection objects. |  
                                          |  |  |  
                                |  |  |  |