How whould I structure a DBNull statement in a single line???

  • Thread starter Thread starter Aaron Ackerman
  • Start date Start date
A

Aaron Ackerman

I want to be able to do the following in a single line.

newDataSetRow.AdditionalHours = if
IsDBNull(vdsPublisherLocal.Tables("CaseInstance").Rows(i).Item("AdditionalHo
urs")) then 0 end if



if the value is null I want to put a valid value in place of the dataset
field, how can i do this?
 
Hi Aaron,

You can using the IIf function, but I find that so bad, that I do not want
to take any time in it.

But if you want to use it, feel free, you just can find is searching for IIf
in MSDN

Cor
 
Aaron Ackerman said:
I want to be able to do the following in a single line.

newDataSetRow.AdditionalHours = if
IsDBNull(vdsPublisherLocal.Tables("CaseInstance").Rows(i).Item("AdditionalHo
urs")) then 0 end if



if the value is null I want to put a valid value in place of the
dataset field, how can i do this?


if isdbnull(vdsPublisherLocal.Tables( _
"CaseInstance").Rows(i).Item("AdditionalHours"))) then

newDataSetRow.AdditionalHours = 0
end if

Instead of using isdbnull you can compare against DBNull.Value.
 
* "Aaron Ackerman said:
I want to be able to do the following in a single line.

newDataSetRow.AdditionalHours = if
IsDBNull(vdsPublisherLocal.Tables("CaseInstance").Rows(i).Item("AdditionalHo
urs")) then 0 end if

\\\
If ... Then newDataSetRow.AdditionalHours = 0
///
 
Aaron Ackerman said:
newDataSetRow.AdditionalHours = if
IsDBNull(vdsPublisherLocal.Tables("CaseInstance").Rows(i).Item("AdditionalHo
urs")) then 0 end if
.. . .
if the value is null I want to put a valid value in place of the dataset
field, how can i do this?

Like this:

newDataSetRow.AdditionalHours _
= IIf( 'LongFieldName' <> DBNull.Value _
, 'LongFieldName' _
, 0 _
)

HTH,
Phill W.
 
Back
Top