Thanks!
Mark
String strApplication=
ConfigurationSettings.AppSettings["some_app_setting"];
if (DBNull.Value.Equals(strApplication))
{
Response.Write("This should print because strApplication is null");
}
"Mark" <mfi...@idonotlikespam.cce.umn.edu> wrote in message
news:%23nuCMnu...@TK2MSFTNGP11.phx.gbl...
DBNull is used to represent NULL values in a database table. Although
the term for the value of an unassigned reference is also "null", they are
not the same thing. Suggest:
...
if (strApplication == null)
{
...
}
Regards,
Dan
Thanks!
Mark
"Mark" <mfi...@idonotlikespam.cce.umn.edu> wrote in message
news:%23nuCMnu...@TK2MSFTNGP11.phx.gbl...
Why are you comparing it against DBNull.Value? Why not just compare it
to null? DBNull is used for database null comparisons (for the most part).
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com
"Mark" <mfi...@idonotlikespam.cce.umn.edu> wrote in message
news:%23nuCMnu...@TK2MSFTNGP11.phx.gbl...
"Mark" <mfi...@idonotlikespam.cce.umn.edu> wrote in message
news:%23dXm2vu...@TK2MSFTNGP09.phx.gbl...
"Mark" <mfi...@idonotlikespam.cce.umn.edu> wrote in message
news:%23dXm2vu...@TK2MSFTNGP09.phx.gbl...
> Checking strApplication == null works, but why doesn't DBNull work?
>
> Thanks!
> Mark
Just to be explicit: A reference variable having the value of "null"
means that the variable does not reference an object instance. That is, a
reference variable can reference an object instance OR be "null", not both.
DBNull.Value is a reference to an object instance (of type DBNull,
confusingly enough). Therefore DBNull.Value is not "null". Don't get hung up
on the fact that DBNull contains the term "Null". Databases and programming
languages happen to use the same term to represent similar concepts.
Regards,
Dan