using vbnull

  • Thread starter Thread starter AussieRules
  • Start date Start date
A

AussieRules

Hi,

I have a sql table with a integer col that is null.

When I assign this to a int value in my vb app with the following code, it
set the intValue to be 0.

This means when I set my text box.text to the value, it displayes 0 rather
than a blank text box.

How do I get around this one ?

If pRow("StreetNo") Is DBNull.Value Then

intStreetNo = Nothing

End If
 
AussieRules said:
Hi,

I have a sql table with a integer col that is null.

When I assign this to a int value in my vb app with the following
code, it set the intValue to be 0.

This means when I set my text box.text to the value, it displayes 0
rather than a blank text box.

How do I get around this one ?

If pRow("StreetNo") Is DBNull.Value Then

intStreetNo = Nothing

End If

Nothing is different from DBNull.Value. Setting an Integer variable to
Nothing is the *same* as setting it to zero because zero is the default
value for the Integer data type. You can neither store Nothing in an integer
variable, nor you can store DBNull.Value there.
 
Armin Zingler said:
Nothing is different from DBNull.Value. Setting an Integer variable
to Nothing is the *same* as setting it to zero because zero is the
default value for the Integer data type. You can neither store
Nothing in an integer variable, nor you can store DBNull.Value
there.

......and: vbNull, as mentioned in the subject is something completely
different again. It is a constant that determines the subtype of a variant
(which doesn't exist anymore in VB.NET).
 
Hi Aussie Rules,

I think something like this.
When I assign this to a int value in my vb app with the following code, it
set the intValue to be 0.

This means when I set my text box.text to the value, it displayes 0 rather
than a blank text box.
How do I get around this one ?
If pRow("StreetNo") Is DBNull.Value Then
mytextbox.text = ""
Else
mytextbox.text = pRow("StreetNo").tostring
End if

I hope this helps

Cor
 
Back
Top