"FormatException was unhandled" Input string was not in a correct format.
Submitted by vaibhav on Wed, 09/23/2009 - 00:11
Hi !
Here I am trying to write a function that returns me value based on the following condition...
IF
Variable is NULL return me DBNull.Value
ELSE
Convert Variable into DataType whose DataTypeCode has been provided to me as a parameter of function.
Now while converting a variable into required DataType an exception is thrown "FormatException was unhandled". Input string was not in a correct format.
How do I resolve this error please help.
Here is my code...
public object ReturnDBNullOrRequiredDatatype(object IsThisObjectANull, TypeCode DataTypeCode) { if (Convert.IsDBNull(IsThisObjectANull) == true) return DBNull.Value; else return Convert.ChangeType(IsThisObjectANull, DataTypeCode); }
Thanks in Advance
Post new comment