The insufferable DBNull Class - Cheap Tricks?

R

Rick Cabral

I am transitioning from ASP 3.0 to ASP.NET (VB), and have
been quite successful.

However, I am frequently tripped up when a DBNull object
or it's DBNull.Value makes its appearance in data-driven
routines.

I don't have the inclination to revise all my TSQL to
NEVER produce NULL values (NULLs are perfectly nice).

How do I protect my explicitly declared Function
parameters from these rogue DBNull objects? I've
tried .ToString-ing them, but that doesn't help my Number
Typed parameters.

Where should I be testing for DBNull? Is there a built-in
conversion routine that turns DBNull into something more
benign? How do I train my Functions to let DBNull through
their parameter list?

Please reply directly to email as well as the newsgroup.
It's murder finding things here.

Thanks
Rick Cabral
 
A

Armin Zingler

Rick Cabral said:
I am transitioning from ASP 3.0 to ASP.NET (VB), and have
been quite successful.

However, I am frequently tripped up when a DBNull object
or it's DBNull.Value makes its appearance in data-driven
routines.

I don't have the inclination to revise all my TSQL to
NEVER produce NULL values (NULLs are perfectly nice).

How do I protect my explicitly declared Function
parameters from these rogue DBNull objects? I've
tried .ToString-ing them, but that doesn't help my Number
Typed parameters.

Where should I be testing for DBNull?

What should happen when the field value is DBNull?
Is there a built-in
conversion routine that turns DBNull into something more
benign? How do I train my Functions to let DBNull through
their parameter list?

If a database field can be DBNull, you must declare the function arguments
"As Object". If you don't need Null values in the database, don't allow
them. If they are allowed you must handle them in the source code.
Please reply directly to email as well as the newsgroup.
It's murder finding things here.


Asked here, answered here. ;-)
 
Top