472,353 Members | 1,510 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

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 13182
'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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: MFRASER | last post by:
How do I test for DBNull? The following does not work. System.Data.DataRow aRow; if (aRow != null) { aServer = (string)aRow; }
1
by: Vern | last post by:
I'm using the Microsoft Enterprise Data Access block to call the stored procedure. One of the values the stored procedure returns is the stop date....
2
by: gn | last post by:
I am a VB.Net newbie and have tried to search for this answer without success - What is the exact syntax to test if...
10
by: Bob | last post by:
I'm sure there's a good reason, I just haven't been able to think of it - why didn't MS allow "DBNull" values to simply be a null (Nothing)? Bob
6
by: cj | last post by:
in the command window I get: ? result {System.DBNull} : {System.DBNull} I need to check for this in code. I then tested in the command...
3
by: AAJ | last post by:
Hi all A quick question on Datasets..... I populate a dataset from a SQL SERVER 2000 database via a data adapter. I then use the dataset to...
19
by: Dave | last post by:
If Iwant to check if dataset1.SelectQuery1.column1 == System.DBNull.Value. How do I do this? What I wrote above will give an error. -- L. A. Jones
0
by: lgalumbres | last post by:
Hello, I have a DataGridView control with a DataGridViewComboBoxColumn that allows users to choose selections from a list. The DataGridView is...
9
by: Robert Bravery | last post by:
HI all, I have a column value returned to a string variable in my c# app. But the return type is of system.dbnull. How can I convert that to a...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

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.