473,217 Members | 1,979 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,217 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 16951
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: cjm | last post by:
I need to group records and assign a setid to the group. I have a table with data that looks like this ColA ColB 94015 01065 94016 01065 94015 01085 94015 01086 33383 00912 32601 00912
15
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...
7
by: Adrian Parker | last post by:
'function to convert null to nothing Function CheckDate(ByVal DRow As DataRow, ByVal strCol As String) As Date If DRow.Item(strCol) Is System.DBNull.Value Then Return Nothing Else Return...
11
by: JohnR | last post by:
I'm trying to find a way to create a variable of a given type at runtime where I won't know the type until it actually executes. For example, dim x as object = "hi" x is declared as an object...
64
by: yossi.kreinin | last post by:
Hi! There is a system where 0x0 is a valid address, but 0xffffffff isn't. How can null pointers be treated by a compiler (besides the typical "solution" of still using 0x0 for "null")? -...
5
by: Phil Latio | last post by:
I have 2 virtually identical tables and wish to move data between them. Basically one table is called "live_table" and the other is named "suspended_table" and the only difference is that the...
31
by: leonm54 | last post by:
I remember that this is a bad practice, but can not find a definitive resource that states it is bad and why. Can anyone help?
4
oll3i
by: oll3i | last post by:
public void wczytajPlik(String sciezka) throws FileNotFoundException { wczytaneDane.setText(""); BufferedReader br = new BufferedReader(new FileReader(sciezka)); String line = null; ...
43
by: emyl | last post by:
Hi all, here's an elementary question. Assume I have declared two variables, char *a, **b; I can then give a value to a like a="hello world";
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.