ASP.Net: Checking a variable for a null value

April 25, 2005

I had to check a variable for a null value today, so I tried the ‘old
fashioned’ (Classic ASP) way:
If IsNull(rs(“Name”)) Then…

This didnt work – Visual Studio complained and told me I should be using
DBNull type, for which the syntax isnt exactly obvious.

Heres what works:
If rsCompany(“Name”) is DBNull.Value then

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: