472,121 Members | 1,486 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Assigning null value to an integer

Roy
Hi all,
How can I assign null to an integer. This doesn't work
Dim intMyValue As Integer
intMyVal = System.DBNull.Value
Thanks in advance,
Roy
Nov 21 '05 #1
4 16589
Roy, the value types are not nullable.

Marcie

On Thu, 12 May 2005 07:54:03 -0700, Roy <Ro*@discussions.microsoft.com> wrote:
Hi all,
How can I assign null to an integer. This doesn't work
Dim intMyValue As Integer
intMyVal = System.DBNull.Value
Thanks in advance,
Roy


Nov 21 '05 #2
Roy
Marcie,
In a report I need to replace a value of integer column from zero to blank.
Any suggestions?

"Marcie Jones" wrote:
Roy, the value types are not nullable.

Marcie

On Thu, 12 May 2005 07:54:03 -0700, Roy <Ro*@discussions.microsoft.com> wrote:
Hi all,
How can I assign null to an integer. This doesn't work
Dim intMyValue As Integer
intMyVal = System.DBNull.Value
Thanks in advance,
Roy


Nov 21 '05 #3
There are 2 things here:

- A integer field in the database can contain nulls, but the Integer type of
the .NET Framework is not nullable. In this case you must create a nullable
type (search Google for some implementations) or to use the Integer value
with a special value to denote null (and zero may not be the best option,
since it can be a valid value depending on your domain)

- You need to convert "0" to "" in your reports. For this you need a
conversion routine, for example i.ToString("#")

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

"Roy" <Ro*@discussions.microsoft.com> escribió en el mensaje
news:95**********************************@microsof t.com...
Marcie,
In a report I need to replace a value of integer column from zero to
blank.
Any suggestions?

"Marcie Jones" wrote:

Nov 21 '05 #4
"Roy" <Ro*@discussions.microsoft.com> schrieb:
How can I assign null to an integer. This doesn't work
Dim intMyValue As Integer
intMyVal = System.DBNull.Value


'Integer' is not nullable. What you can do is writing a wrapper class
around 'Integer' that provides support for a 'null' value, use 'SqlInt32'
instead or wait for .NET 2.0 which contains nullable types.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Adrian Parker | last post: by
64 posts views Thread by yossi.kreinin | last post: by
31 posts views Thread by leonm54 | last post: by
43 posts views Thread by emyl | last post: by
reply views Thread by leo001 | last post: by

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.