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

how to test for System.DBNull

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


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

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

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

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