Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

PRB: 80004005 Unspecified Error When Passing Disconnected Recordset from MTS to ASP

View products that this article applies to.


When passing a disconnected ActiveX Date Objects (ADO) Recordset from a Component Object Model (COM) component inside a Microsoft Transaction Server (MTS) Server Package/COM+ Application to Active Server Pages (ASP), you may receive one of the following error messages:
error '80004005'
Unspecified error
/xxx.asp, line x
-or- (with ASP error handling)
Error Number : 13 - Source : Microsoft VBScript runtime error - Type mismatch
-or- (after multiple tries)
Microsoft VBScript runtime error '800a0007'
Out of memory: 'obj.TestRS'
/xxx.asp, line x

↑ Back to the top


An error occurs because the fields in the disconnected recordset have been defined as adVariant, and ADO cannot marshal certain data types within adVariant across process boundaries (in this case, between InetInfo and MTS or COM+). ADO marshaling cannot convert data of the following types when the field type is set to adVariant:
DBTYPE_ARRAY = 0x2000,
DBTYPE_BYREF = 0x4000,
Please note that the following types are not to be used for Automation when using adVariant, as documented (search for the Topic "Type Indicators" in the Microsoft Data Access Components 2.5 SDK - OLE DB Programmer's Reference in the MSDN library at
// The following values exactly match VARENUM
// in Automation but cannot be used in VARIANT.
DBTYPE_I8 = 20,
DBTYPE_UI8 = 21,

↑ Back to the top


When trying to pass values of the types mentioned above, such as strings (BSTR), you must declare those field types explicitly instead of using adVariant.


    rs.Fields.Append "ID", adVariant 'this works since it is an Integer
    rs.Fields.Append "fname", adVarChar, 50
    rs.Fields.Append "lname", adVarChar, 50

↑ Back to the top

More information

Steps to Reproduce Behavior

  1. In Microsoft Visual Basic 6.0, create a new ActiveX DLL project.
  2. Add the following references to the project:
    Microsoft Transaction Server Type Library
    (NOTE: Under Windows 2000, select COM+ Services Type Library instead of Microsoft Transaction Server Type Library)

    Microsoft ActiveX Data Objects Library
  3. Copy and paste the following code into the Class Module:
    Public Function TestRS() As Variant
        Dim rs As ADODB.Recordset
        Set rs = GetObjectContext.CreateInstance("ADODB.Recordset")
        rs.Fields.Append "ID", adVariant
        rs.Fields.Append "fname", adVariant
        rs.Fields.Append "lname", adVariant
        rs.CursorLocation = adUseClient
            rs(0) = 1
            rs(1) = "Yuri"
            rs(2) = "Lausberg"
        Set TestRS = rs.Clone
        Set rs = Nothing
    End Function
  4. Set the Class Property MTSTransactionMode = 1 NoTransactions.
  5. Compile the DLL.
  6. Add the DLL to an MTS Server Package or a COM+ Application.
  7. Copy and paste the following ASP script into a new ASP file.
      On Error Resume Next 
      Set obj = Server.Createobject("project1.class1")
      Set rs = obj.TestRS
      Response.Write rs(1)
      If Err.Number > 0 Then
        Response.Write "<B>Unable to read field value</B><P>"
        Response.Write "Error Number : "& Err.Number
        Response.Write " - Source : " & Err.Source
        Response.Write " -  " & Err.Description & "<P>"
        Response.Write rs(2)
      End If
      Set rs = Nothing
  8. Request the ASP file from a browser, and the following error appears:
    Unable to read field value

    Error Number : 13 - Source : Microsoft VBScript runtime error - Type mismatch

↑ Back to the top

Keywords: kbcodesnippet, kbdatabase, kberrmsg, kbprb, KB237536

↑ Back to the top

Article Info
Article ID : 237536
Revision : 5
Created on : 7/16/2004
Published on : 7/16/2004
Exists online : False
Views : 430