Solved

Strongly typed dataset Null Values Causes Exception

Posted on 2008-10-07
7
887 Views
Last Modified: 2013-11-26
I got a table that has columns that are int type that allow for nulls.  I used VS2005 dataset designer to create strongly typed dataset.  When I retrieve rows that have null values in those columns an exception is thrown.

Has anybody got a workaround to this.  I was thinking of changing type to string since in VS that is the only type I can set it not to throw exception then in my BLL convert it to nullable(of Integer).

Any ideas would certainly help.

Thank you

Rick
0
Comment
Question by:boricua1213
  • 3
7 Comments
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 22663334
Have you tried typing the columns as Nullables?
0
 
LVL 2

Author Comment

by:boricua1213
ID: 22663396
Well,

in the properties of the column in the dataset AllowDBNull is set to True.

And in SQL the column is nullable.

What exactly do u mean by "typing the columns as Nullables"?

Rick
0
 
LVL 23

Accepted Solution

by:
Jens Fiederer earned 250 total points
ID: 22663522
I was thinking of an approach like in
http://blogs.msdn.com/erickt/archive/2008/05/15/datasets-and-nullable-types.aspx
but that is VS2008, sorry.
0
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 22663667
With 2005, you just have to keep using IsNull before referencing the column.
0
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 250 total points
ID: 22664029
With 2005, I would agree that you could use a String type, and set NullValue = (Empty) in the DataSet designer, and then cast it to a Nullable(Of Integer) in the BLL.


DataSet-Designer-NullValue.png
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now