I've the following function which was based on this inital Generic function to handle DataType Conversion
public static T ConvertFromDB<T>(object value)
{
return value == DBNull.Value ? default(T) : (T)Convert.ChangeType(value, typeof(T));
}
It works fine. However when passing in a double like 0 I get the following exception;
Invalid cast from 'System.Double' to 'System.Nullable`1[[System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]'.
I've tried casting as a float but still the same. Any ideas why this is happening ?