更新时间:2023-02-14 20:11:06
所以EX.GetValue(a, b,c)
返回数据集
对象。您正在查看第一个表,查看第一行,并返回第一列中的值。
问题是,这是对象
,你的属性需要Decimal
。框架可以通过做出***猜测来处理这个问题,但有时它会猜错。这就是为什么我发现***使用Option Explicit = True
编写和编译我的应用程序,它告诉编译器不做任何假设并将其标记为错误。
在分配结果之前尝试显式转换结果,看看它是否有任何区别:
SoEX.GetValue(a, b, c)
returns aDataset
object. You are taking the first table, looking at the first row, and returning the value in the first column.
Problem is, that is anObject
, and your property expects aDecimal
. The Framework can handle this by making a best guess, but sometimes it guesses wrong. This is why I find it best to write and compile my apps withOption Explicit = True
, which tells the compiler not to make ANY assumptions and just flag it as an error.
Try explicitly converting the result before assigning it, and see if it makes any difference:
Value = CDbl(EX.GetValue(a, b, c).Tables(0).Rows(0)(0))
要检查的另一件事是验证数据库中的值是否为您期望的价值:实际上可能是12而不是0.012。
The other thing to check is to verify that the value in the database is the value you are expecting: it may actually be 12 rather than 0.012.