473,499 Members | 1,727 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to detect a null value

What is the correct syntax to detect whether a DataTable Row.ItemArray
element is a null value?

using:

if (row.ItemArray[i] == null )

does not seem to work.

Thanks,

Keith
Mar 17 '06 #1
4 4208
That should test for null ok. Sure it is not empty (i.e.
row.ItemArray[i].Length == 0 )?

--
William Stacey [MVP]

"keithb" <kb******@dslextreme.com> wrote in message
news:eB**************@TK2MSFTNGP14.phx.gbl...
| What is the correct syntax to detect whether a DataTable Row.ItemArray
| element is a null value?
|
| using:
|
| if (row.ItemArray[i] == null )
|
| does not seem to work.
|
| Thanks,
|
| Keith
|
|
Mar 17 '06 #2
What is the correct syntax to detect whether a DataTable Row.ItemArray
element is a null value?


Database NULL values are represented by the DBNull type, so try

if (row.ItemArray[i] == DBNull.Value )
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Mar 17 '06 #3
Jay
Hi Keith,

for DataTables and DataRows you can use System.DbNull.Value for
comparison. This will surely work.

Mar 18 '06 #4
keithb wrote:
What is the correct syntax to detect whether a DataTable Row.ItemArray
element is a null value?

using:

if (row.ItemArray[i] == null )

does not seem to work.


As others have said, you can compare to DBNull.Value. Another option is to
call Convert.IsDBNull(row.ItemArray[i]).
--
Tom Porterfield

Mar 20 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
27738
by: John Morgan | last post by:
In an SQL statement which concatenates several fields I get a null value returned if any one of the fields are null. Is this to be expected? For example : SELECT tblMember.memberAddress + '...
3
7045
by: Robb Gilmore | last post by:
Hello, We have a C#.NET app which is calling a Java webservice. We use the wsdl file exportted from the java webservice to create our web-reference in Visual Studio. We are able to create the...
3
10114
by: charliewest | last post by:
Hi - I need to detect when the ExecuteScalar() method of the cmd object returns NULL. I have tried the below code, however, it always returns false (this is to say, that ExecuteScalar never...
15
29186
by: TC | last post by:
What does it mean for an integer to have a null value? I am trying to use the DataView.Find method. That method has an integer return type which contains the "index of the row in the DataView...
1
11453
by: David Shorthouse | last post by:
Hey folks, I am attempting to pass null as the input value from a series of textboxes if the user does not input a value prior to submit. To try and do this, I am using a vbscript function on...
2
2137
by: shankwheat | last post by:
I'm having trouble adding two values together when one of them has a null value // These two values come from a database CEOBonusValue = 550000 CEONonEqIncentCompHidden == null This should...
2
1999
by: Jeff | last post by:
hi ..net 2.0 IDataReader reader; if (reader == null) { } This if test don't come true. I've just tested it with a NULL value in
0
3044
prabirchoudhury
by: prabirchoudhury | last post by:
CRITERIA; +-------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+--------------+------+-----+---------+-------+...
2
14641
by: qwedster | last post by:
Folk! How to programattically check if null value exists in database table (using stored procedure)? I know it's possble in the Query Analyzer (see last SQL query batch statements)? But how...
0
7006
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
7169
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,...
1
6892
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7385
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
5467
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,...
0
3096
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3088
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1425
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
294
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.