【发布时间】:2011-12-16 19:18:54
【问题描述】:
我正在使用 OleDb 查询 Oracle 10g 数据库。
我的查询非常简单,只需从给定表中获取 COUNT 条记录。
在使用 ExecuteScalar 时,我在尝试将结果值转换为 Int 时遇到了转换错误。检查类型,结果是 System.Decimal。
现在,我已经看到其他用户在使用 ID 时遇到了类似的问题,但在这种情况下,我只是返回了一个预期为整数的计数,那么我为什么还要强制转换它呢?
SQL 如下。
_sqlText = @" select count(*) as num_records from ce_quote_ext
where ce_quoteid in (select ce_quoteid from ce_quote where opportunityid in
(select opportunityid from ce_quote where ce_quoteid = '?' )) and custsign = 'T' ";
【问题讨论】:
-
查看使用的 oracle 驱动程序规范。它可以为数字指定超类型,为紧凑性指定其他类型。