469,304 Members | 2,303 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,304 developers. It's quick & easy.

how to test for System.DBNull

How can I test to see if an object is System.DBNull? I have an event and
need to get the value from a parameter like this:
Private Sub ValueChanged(ByVal sender As Object, ByVal e As
System.EventArgs)
Try
Dim ID As Int32
'Next line is suto code. it doesnt compile
If sender.Value Is System.DBNull Then
ID = 0
Else
ID = sender.Value
End If
If I put a watch on "sender.Value" its value is {System.DBNull}.

Thanks.

--
mo*******@nospam.com
Nov 21 '05 #1
4 13051
'Next line is suto code. it doesnt compile
If sender.Value Is System.DBNull.Value Then
ID = 0
Else
ID = sender.Value
End If

Chris
"moondaddy" <mo*******@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
How can I test to see if an object is System.DBNull? I have an event and
need to get the value from a parameter like this:
Private Sub ValueChanged(ByVal sender As Object, ByVal e As
System.EventArgs)
Try
Dim ID As Int32
'Next line is suto code. it doesnt compile
If sender.Value Is System.DBNull Then
ID = 0
Else
ID = sender.Value
End If
If I put a watch on "sender.Value" its value is {System.DBNull}.

Thanks.

--
mo*******@nospam.com

Nov 21 '05 #2
Moondaddy,

Value is not a member of object

However the sender is the object that is sending this object and because
that every object derives from object, can you forever (direct)cast it.

Therefore it probably has to be something as
\\\\
DirectCast(sender, YourSendingObjectType).value Is Dbnull.value.
////

I hope this helps,

Cor
Nov 21 '05 #3
THANKS! That did it!

--
mo*******@nospam.com
"Chris" <No****@NoSpam.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
'Next line is suto code. it doesnt compile
If sender.Value Is System.DBNull.Value Then
ID = 0
Else
ID = sender.Value
End If

Chris
"moondaddy" <mo*******@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
How can I test to see if an object is System.DBNull? I have an event and
need to get the value from a parameter like this:
Private Sub ValueChanged(ByVal sender As Object, ByVal e As
System.EventArgs)
Try
Dim ID As Int32
'Next line is suto code. it doesnt compile
If sender.Value Is System.DBNull Then
ID = 0
Else
ID = sender.Value
End If
If I put a watch on "sender.Value" its value is {System.DBNull}.

Thanks.

--
mo*******@nospam.com


Nov 21 '05 #4
"moondaddy" <mo*******@nospam.com> schrieb:
How can I test to see if an object is System.DBNull? I have an event and
need to get the value from a parameter like this:

Private Sub ValueChanged(ByVal sender As Object, ByVal e As
System.EventArgs)
Try
Dim ID As Int32
'Next line is suto code. it doesnt compile
If sender.Value Is System.DBNull Then


\\\
If sender.Value Is DBNull.Value Then
...
End If
///

--
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

4 posts views Thread by MFRASER | last post: by
10 posts views Thread by Bob | last post: by
6 posts views Thread by cj | last post: by
3 posts views Thread by AAJ | last post: by
9 posts views Thread by Robert Bravery | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.