ADO Recordset十进制值问题 [英] ADO Recordset Decimal value issue

查看:92
本文介绍了ADO Recordset十进制值问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码类似于

Dim A, B, C
Set rs = Server.CreateObject("ADODB.Recordset")
strSql = "Exec [dbo].[some_sp] IND"
rs.open strSql,CN,3,3

Do While Not rs.EOF

'these columns are returned as decimal(10,2) format
A = rs("col1")
B = rs("col2")

rs.MoveNext
Loop

C = A + B 'i get type mismatch error here

然后我使用response.write检查A,B
的值,它们是整数格式而不是十进制

And I used response.write to check values for A, B they are in integer format and not decimal

我是否必须重新格式化记录集以设置十进制值?
而且类型不匹配可能会出现问题,因为所有值都是整数(即使它们是十进制)?

Do i have to format recordset again to set decimal values? And what could be possible problem for type mismatch as all values are integer (even if they are decimal) ?

推荐答案

ASP / VBScript中的变量只是变量类型,因此您可能需要显式转换值。

Variables in ASP/VBScript are just variant types so you may need to convert the values explicitly.

C = CDbl(A) + CDbl(B)

但是,我的猜测是您的某行没有数字col1或col2的值。当您收到类型不匹配错误时,您知道这些值是什么吗?

However, my guess would be that one of your rows does not have a numeric value for col1 or col2. Do you know what the values of those are when you get the type mismatch error?

这篇关于ADO Recordset十进制值问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆