I want to fetch float data from sql server database 2008 R2.
In database there are two fields estimated_amount and actual_amount.
At first only estimated-amount filled contains value, and the actual_amount field is containing NULL.
The problem is that when I fetch data and parse the value it shows error:
System.FormatException was unhandled by user code Message=Input
string was not in a correct format. Source=mscorlib
My code is :
CRM_Doctor_RequestObj.Actual_Amount = float.Parse(Convert.ToString(row["Actual_Amount"]));
Please suggest what I can do..
Write less code and avoid translating to string. You will have to deal with the null separately – Depending on what
rowis, it may support anIsNull/IsDBNullmethod, so it would be more like: