Today I got "Cannot cast DBNull.Value to type 'System.DateTime'. Please use a nullable type." error in the C# application. After my trace, it is caused by this line: DateTime? moveOutDate = dt.Rows[0].Field ("MoveOutDate"); You should make it as: DateTime? moveOutDate = dt.Rows[0].Field ("MoveOutDate");
Comments