PDA

View Full Version : Null Values in Access Database: How to handle


Scott
11-07-2004, 02:43 AM
Try explicitly casting the database balue to string, i.e.,
DateSold = Row.Item("DateSold").ToString

arnold2004
11-07-2004, 02:57 AM
I hope someone out there has a good suggestion. I have an access database with cells I want to display however some of the cells may have Null values or otherwise empty. I want these cells if empty to display as empty on my website that accesses the database. How do I test for a null value.

Cast from type 'DBNull' to type 'Date' is not valid.

&

Cast from type 'DBNull' to type 'String' is not valid.

on these lines

DateSold = Row.Item("DateSold")
Comments = Row.Item("Comments")

How can I handle Null values from cells?

roryknowles
11-09-2004, 03:59 AM
Here is a function I use, normally for GetRows also:


FUNCTION isNul( value )
IF ISNull(value) or value = "" THEN
isNul = ""
ELSE
isNul = value
END IF
END FUNCTION</CODE>





then just call it like this:


DateSold = isNul(Row.Item("DateSold"))

arnold2004
11-09-2004, 07:54 AM
Thank you this really helped.