仅当我在SQL中包含c.item_cost
时,从Oracle数据库中提取的此SqlDataSource会引发“指定的强制转换无效”。如果我删除此列,则不会出现错误。如果我真的在代码中引用该字段并不重要。SqlDataSource在从Oracle提取的数据上抛出“指定的强制转换无效”错误
<asp:SqlDataSource ID="mySqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:myConnectionString %>" ProviderName="Oracle.ManagedDataAccess.Client"
SelectCommand="select msi.segment1 partnumber,
msi.description,
msi.primary_uom_code uom,
c.item_cost
from apps.cst_item_costs c, apps.mtl_system_items_b msi, APPS.ORG_ORGANIZATION_DEFINITIONS org
and msi.organization_id=org.ORGANIZATION_ID
and c.organization_id=org.ORGANIZATION_ID
and c.cost_type_id=1
and ((msi.inventory_item_id=c.inventory_item_id)
and (msi.organization_id=c.organization_id))
order by msi.segment1">
另外,如果我加入SQL修剪的行数下降到一个小数目,不是抛出的错误。我猜这是导致问题的列中的一些数据。
SqlDataSource是否对数据类型做出了一些假设?
即使我可以精确定位数据,这似乎都是有效的小数,如何避免这个错误?
如果需要更多信息,请让我知道。我目前正在试图找出导致这种情况的数据,但一些似乎是有效的小数,尽管有些数字更多。 SQL可以成功运行诸如TOAD之类的数据库工具。
更新:c.item_cost
中的值是15.032221226116,它比其他数据的小数位数多得多。
可能的类型从Oracle到.NET翻译你真的需要所有价格的精确度? ROUND(c.item_cost,6)是否会抛出错误? – kevinsky
@kevinsky它的工作原理。同时,我可以ROUND(c.item_cost,12),它仍然有效。不是我能够绕多远,但你让我感动。写下来,我会接受。 –