By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,475 Members | 954 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,475 IT Pros & Developers. It's quick & easy.

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

P: n/a
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?
Nov 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Cor
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

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?

Nov 20 '05 #2

P: n/a
"Aaron Ackerman" <no@spam.com> schrieb
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.

--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3

P: n/a
* "Aaron Ackerman" <no@spam.com> scripsit:
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
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4

P: n/a
"Aaron Ackerman" <no@spam.com> wrote in message
news:e0**************@TK2MSFTNGP11.phx.gbl...
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.
Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.