DataColumn.Expression IsNull

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Need to return a calculated column in a dataset that indicates whether another column contains a dbnull value. Note this data does not come from any sort of datasource in which I could perform such a calculation.

I initially thought Id be able to use the IsNull function but this appears to be badly named and performs a similar function to Nz within Acces. That is, it is used to convert a value from a null into some default value.

I then thought Id be able to use a combination of isnull & iif, for example

iif(IsNull(myColumn, -1)=-1, -1, 0)

Unluckily since the data type of my column is a number which could contain -1, this wont work too well

Does anyone have any other ideas? Thanks in advance.
 
Badly named? It's pretty much identical to Sql Server's isn't it?

You can still set it to a known value that will conform to the type spec and
then check that with another expression. So a column named Evaluater for
instance could have IsNull(yourColumn, ConformingValue) then another
expression of type int could check for ConformingValue and be 0 or -1
accordingly. AFAIK this should work.

--

W.G. Ryan, eMVP

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/community/newsgroups
AndyG said:
Need to return a calculated column in a dataset that indicates whether
another column contains a dbnull value. Note this data does not come from
any sort of datasource in which I could perform such a calculation.
I initially thought Id be able to use the IsNull function but this appears
to be badly named and performs a similar function to Nz within Acces. That
is, it is used to convert a value from a null into some default value.
I then thought Id be able to use a combination of isnull & iif, for example

iif(IsNull(myColumn, -1)=-1, -1, 0)

Unluckily since the data type of my column is a number which could
contain -1, this wont work too well
 
Back
Top