473,405 Members | 2,282 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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

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
4 1179
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
"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
* "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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: jim | last post by:
This line of code returns error 13, cast from 'DBNull' to type 'String' is not valid If IsDBNull(Clinics.Clinics.Item(A).Workphone) The <other code End I Clinics.Clinics is a dataset that...
5
by: DraguVaso | last post by:
Hi, Something I don't understand about a Typed DataSet: When a value in the DataSet is DBNull, it throws this error: "Cannot get value because it is DBNull". But aren't Typed DataSets...
5
by: Mark | last post by:
Assume that "some_app_setting" does not exist in my web.config file. Then, the first line of code below assigns the value null to strApplication. Why doesn't my IF statement return true, and...
7
by: | last post by:
Source Error: Line 173: sData(rownumber - 1, lcnt) = WhatCol.Value Line 174: End IF Line 175: If (sData(rownumber, lcnt) = sData(rownumber - 1, lcnt)) AND...
6
by: tshad | last post by:
The error I am getting is: ******************************************************************* Exception Details: System.InvalidCastException: Cast from type 'DBNull' to type 'String' is not...
3
by: giant food | last post by:
since I can't specify an integer to be null (i.e. undefined), I'd like to create a structure that provides the same functionality, like: Public Structure NullableInt Private i As Integer...
6
by: tshad | last post by:
I have a value coming from my Object (or it could also be from a SqlDbReader) where I need to test for DBNull and 0. I tried to do it in one call: if (not (newPosition.ReportsTo is...
6
by: Charlie Brown | last post by:
When checking for NULL values from a database, normally I would use If Not row("NetSales") Is DBNull.Value Then NetSales = row("NetSales") End If However, if I use a typed dataset then I...
19
by: Dave | last post by:
If Iwant to check if dataset1.SelectQuery1.column1 == System.DBNull.Value. How do I do this? What I wrote above will give an error. -- L. A. Jones
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.