This SqlDataSource, which is pulling from an Oracle db, throws "Specified cast is not valid" ONLY when I include c.item_cost
in the SQL. If I remove this column, no error. It does not matter if I actually reference the field in code.
<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">
Also, if I add SQL to trim the number of rows down to a small number, the error is NOT thrown. I'm guessing it's some piece of data in the column causing the issue.
Is the SqlDataSource making some assumptions on datatypes?
Even if I can pinpoint the data, which appears to all be valid decimals, how can this error be avoided?
Please let me know if more information is needed. I am currently trying to pinpoint the data that causes this but everything appears to be a valid decimal though some have more digits. The SQL does successfully run with a db tool such as TOAD.
Update: The value in the c.item_cost
is 15.032221226116 which is far more decimal digits than other data.