Click here to Skip to main content
15,912,329 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am facing problem to store a value in database of type Decimal(4,4). On entering the value in txtbox it throws an exception 'Error converting data type numeric to decimal.'
Please help me for solution
Posted
Comments
rajeevcapgeminiindia 23-Nov-11 3:32am    
I think it is not possible like decimal(4,4) because before decimal no value is there.

Decimal (4,4) means total length is 4, out of which 4 are reserved for decimal. Then nothing will be before decimal.


Ex Decimal(10,8) means total length 10 out of which 8 before decimal and 2 after decimal.



So increase the length of your field in database
 
Share this answer
 
Comments
waqar ahmad (Dev) 29-Nov-11 5:40am    
I fix my problem from your reply. I set decimal(8,4) for decimal value 4,4. Now when these values saved, are automatically round off e.g when I enter value 2.369 it will convert automatically 2.3700. I want to prevent it for automatically conversion.
Hope you have solution of my problem
RaisKazi 29-Nov-11 6:50am    
My 5.
Anuja Pawar Indore 29-Nov-11 6:55am    
Thanks RaisKazi
Use Round function, in this when third parameter is not 0, then it truncates rather than rounds
SQL
ROUND ( 123.456 , 2 , 1 )

Further you can refer
http://msdn.microsoft.com/en-us/library/ms175003(SQL.90).aspx[^]
 
Share this answer
 

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