Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 195180 - Last Review: December 3, 2003 - Revision: 3.1
PRB: VBScript "Type Mismatch" Error When Field Type Is adNumeric
This article was previously published under Q195180
When you perform a numeric comparison or calculation on an adNumeric (131)
field type using VBScript, the following errors may be returned:
Microsoft VBScript runtime error '800a000d'
Type mismatch
Microsoft VBScript runtime error '800a01ca'
Variable uses an Automation type not supported in VBScript
The errors occur because VBScript cannot properly convert adNumeric values
to a valid numeric type.
You can use either of the following two possible workarounds:
- Convert the adNumeric field using CDbl() (or CInt()) as in the
following example:
<%@ LANGUAGE="VBScript"%>
<%
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open "MyDSN", "MyUserID", "MyPassWord"
set oRS = oConn.Execute("Select list_price FROM DEMO.PRICE")
Response.Write("List Price * 100 = " & CDbl(oRS("list_price")) * 100)
%>
-or-
-
Use JScript, because JScript does not exhibit this behavior.
Steps to Reproduce the Behavior
The following code exhibits the above-mentioned error:
<%
Set oConn = Server.CreateObject("ADODB.COnnection")
oConn.Open "MyDSN", "MyUserID", "MyPassWord"
set oRS = oConn.Execute("Select list_price FROM DEMO.PRICE")
'This is the bad line of code, "list_price" is being returned as
'type adNumeric.
Response.Write("List Price * 100 = " & oRS("list_price") * 100)
%>
APPLIES TO
- Microsoft Open Database Connectivity 2.5
- Microsoft ActiveX Data Objects 1.0
- Microsoft ActiveX Data Objects 1.5
- Microsoft ActiveX Data Objects 2.0
- Microsoft ActiveX Data Objects 2.5
- Microsoft ActiveX Data Objects 2.6
- Microsoft ActiveX Data Objects 2.7
- Microsoft Data Access Components 1.5
- Microsoft Data Access Components 2.0
- Microsoft Data Access Components 2.5
- Microsoft Data Access Components 2.6
- Microsoft Data Access Components 2.7
- Microsoft Active Server Pages 4.0
- Microsoft Open Database Connectivity Driver for Visual FoxPro 5.0
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate