我正在查詢使用OleDb的Oracle 10g數據庫。爲什麼OleDb ExecuteScalar方法在查詢COUNT時返回Decimal?
我的查詢非常簡單,只是從給定的表中獲得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驅動程序規範。它可以爲數字和其他類型指定超類型以實現緊湊。 – 2011-12-16 19:39:38