Check for Null on DB Field

shilps

New Member
I have an Access 2000 DB that I connect to and do select queries against. One of the fields is a Description field that may or may not contain data. When looping through the recordset using ASP.NET my application crashes if it hits a record that has a NULL entry. I need to do a check for NULL on this field before outputting the data but am just starting with .NET - there is no IsNull function that I can find nor can I simply do a If DBField = "" anymore......what's the new solution to check and see if the DB field is null or not???<BR><BR>Thanks!nope, no more IsNull() but there is IsDBNull() and it works great. In some other cases you may want to check:<BR><BR>If oObj Is Nothing....<BR><BR>that still works tooYou could also check for nulls with in the SQL statement using the syntax below. It works in SQL Server, but I haven't tested it in Access.<BR><BR>"SELECT field1, field2, ISNULL(field3, '') as field3 FROM dbtable"<BR><BR>This would take any NULL instances of field3 and make them an empty string. If the field is an integer, you could use ISNULL(field3, 0) to make it zero.
 
Back
Top