Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP data type problem

Status
Not open for further replies.

Spork52

Programmer
Nov 20, 2007
134
US
I am retrieving two numeric values from a SQL Server table (both have precision 7 and scale 2) and then attempting subtraction with vbScript. Keep getting the "Type Mismatch" error. When I test the data types with vartype and typename functions I get vartype = 14 for both (which I thought meant decimal), but typename give me this

Microsoft VBScript runtime error '800a01ca'
Variable uses an Automation type not supported in VBScript: 'TypeName'

If I apply CStr or CDbl to both values then subtraction works.

What's going on here? What is the data type and why do I have to coerce the data types before subtraction?
 
For numeric accuracy, db's usually support more data type than vbscript is prepared to support. vt_decimal is one of those. It is not hopeless for vb-scripter: it can still hold the data vt_decimal included, only you have to convert it to double or float or currency before doing arithmetic with it. Here is a summing up by the insider.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top