Click here to Skip to main content
15,892,697 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Oracle Column Data Type NUMBER(28,2) is giving error when trying to convert it into linq,
C#
let _number=p.Field<double>("Number")



error is Specified cast is not valid.
Posted
Updated 22-Jun-14 3:02am
v2
Comments
CHill60 22-Jun-14 9:17am    
Could this be because you've used a reserved word ("Number") as a column name?
ashok rathod 23-Jun-14 0:54am    
you can check and verify that first to convert your respective string to string and then cast it to specific type double
V. 23-Jun-14 7:38am    
Avoid having "keywords" as column names as it can give you problems.
Secondly were is it going wrong? Can you step into the code until this line, hightlight "p.Field<double>("Number")", right-click and choose quickwatch. it will give you the value and the type normally. Decimal should convert to double without issues normally. Not sure how the let keyword reacts to this, can you remove it just to test?
[EDIT]It can very well be that decimal does not convert to double implicitly, so better check that indeed.[/EDIT]

1 solution

Use decimal instead of double
 
Share this answer
 
Comments
Bernhard Hiller 24-Jun-14 3:12am    
Also Oracle's "Number" definition is not fully compatible with .Net's "decimal": it could be necessary to use the "truncate" function in the SQL query to cut the number down to a number which can be represented by a "decimal".

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900