473,396 Members | 1,834 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,396 software developers and data experts.

Generated DataTables and handling null values

Hello:

Is there a way to handle null values for ints, DateTime, etc. in
generated DataTables?

It seems it is not something the Microsoft crew thought of. That is
hard for me to believe.

Thanks,
Travis
Nov 27 '07 #1
2 1733
Travis,

While I don't like it, for typed data sets, you have to use the
Is<column>Null property to determine if the value in a particular column is
null. It sucks, trust me.

If you are checking against a value in a plain old data row, then you
can check against the static Value field on the DBNull class. If the value
in the field is null, then it will return true when compared to that.
Otherwise, you can get your scalar value.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<je**********@gmail.comwrote in message
news:3a**********************************@r60g2000 hsc.googlegroups.com...
Hello:

Is there a way to handle null values for ints, DateTime, etc. in
generated DataTables?

It seems it is not something the Microsoft crew thought of. That is
hard for me to believe.

Thanks,
Travis
Nov 27 '07 #2
On Mon, 26 Nov 2007 20:03:13 -0800 (PST), "je**********@gmail.com"
<je**********@gmail.comwrote:
>Hello:

Is there a way to handle null values for ints, DateTime, etc. in
generated DataTables?

It seems it is not something the Microsoft crew thought of. That is
hard for me to believe.

Thanks,
Travis
Another option is if(String.IsNullOrEmpty(dr[n].ToString()))
before trying to use the value.
nullable types may also be of use to you for your value types.
hth
Bob
Nov 27 '07 #3

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

Similar topics

4
by: Brendan McLoughlin | last post by:
Hi, I am looking for opinions and alternatives for handling null values in a data object which reads a record from a database table. This object will have properties which will be populated...
2
by: xAvailx | last post by:
I have a requirement that requires detection of rows deleted/updated by other processes. My business objects call stored procedures to create, read, update, delete data in a SQL Server 2000 data...
3
by: James Foreman | last post by:
I've got a set of emails in a table, where sometimes they've failed to input the @ properly. Eg james.foreman'abcmail.co.uk How do I write a replace to deal with that? Also, I've got a set...
2
by: Jenny K | last post by:
Hi everyone, I've got a console application that grabs data into 3 datatables asynchronously, and writes each datatable's data to a textfile. The problem is that the data returned by each sproc...
1
by: DKode | last post by:
I find myself writing repetitive functions for handling null values from my DB like so: Private Function SetDateNull(ByVal p_date As Object) As Date If (TypeOf (p_date) Is System.DBNull) Then...
5
by: Frank | last post by:
Hello All, I am working on a vb.net app where I need to compare to 2 datatables and determine if a string exists in one or both. The first dt is filled from the db. A form is loaded and the...
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...
5
by: Veeru71 | last post by:
Given a table with an identity column (GENERATED BY DEFAULT AS IDENTITY), is there any way to get the last generated value by DB2 for the identity column? I can't use identity_val_local() as...
2
by: riltim | last post by:
Hi, I have a situation where I need to take multiple DataTables and convert them to a single Datatable which would be simple if I didn't need to convert them into a matrix where like items will...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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
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.