What .NET method has this error message: “Object cannot be cast from DBNull to other types”
The stack traces have been stipped from my logs so I’m looking for a starting point.
Answers:
Convert.ToInt32: “Object cannot be cast from DBNull to other types.”- VB’s
CInt: “Conversion from type ‘DBNull’ to type ‘Integer’ is not valid.” - C#’s
(int): “Specified cast is not valid.” Int32.Parse(x.ToString()): “Input string was not in a correct format.”
It’s probably a Convert.To_ method or something similar, but I don’t know that that will give you much insight into finding it. This error is raised when you’re trying to use a value you got from a database (and it’s null), though, so I would start by looking at where you’re getting your data from.