By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,702 Members | 1,432 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,702 IT Pros & Developers. It's quick & easy.

Assigning null value to an integer

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
"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.