Microsoft KB Archive/237536

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

Article ID: 237536

Article Last Modified on 7/16/2004

-

APPLIES TO


 * Microsoft Data Access Components 2.0
 * Microsoft Data Access Components 2.1
 * Microsoft Data Access Components 2.1 Service Pack 2
 * Microsoft Data Access Components 2.1 Service Pack 1
 * Microsoft Data Access Components 2.1 Service Pack 2
 * Microsoft Data Access Components 2.5
 * Microsoft Data Access Components 2.6
 * Microsoft Data Access Components 2.7
 * Microsoft Internet Information Server 4.0
 * Microsoft Internet Information Services 5.0
 * Microsoft Active Server Pages 4.0
 * Microsoft Transaction Services 2.0
 * Microsoft COM+ 1.0

-



This article was previously published under Q237536



SYMPTOMS
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



CAUSE
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_BSTR = 8,

DBTYPE_IDISPATCH = 9,

DBTYPE_VARIANT = 12,

DBTYPE_IUNKNOWN = 13,

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 http://msdn.microsoft.com/library/psdk/dasdk/olpr0vu6.htm):

// The following values exactly match VARENUM

// in Automation but cannot be used in VARIANT.

DBTYPE_I8 = 20,

DBTYPE_UI8 = 21,

DBTYPE_GUID = 72,

DBTYPE_VECTOR = 0x1000,

DBTYPE_FILETIME = 64,

DBTYPE_RESERVED = 0x8000,



RESOLUTION
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.

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



Steps to Reproduce Behavior
 In Microsoft Visual Basic 6.0, create a new ActiveX DLL project. 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

  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.Open rs.AddNew rs(0) = 1 rs(1) = "Yuri" rs(2) = "Lausberg" rs.Update Set TestRS = rs.Clone rs.Close Set rs = Nothing GetObjectContext.SetComplete End Function  Set the Class Property MTSTransactionMode = 1 NoTransactions. Compile the DLL. Add the DLL to an MTS Server Package or a COM+ Application.</li>  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>" Else Response.Write rs(2) End If rs.Close Set rs = Nothing %>                   </li> 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

</li></ol>

Additional query words: error 80004005 13 800a0007

Keywords: kberrmsg kbcodesnippet kbdatabase kbprb KB237536

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.