473,396 Members | 1,989 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,396 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 13232
'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. When the stop date is null, the program crashes....
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 HttpContext.Current.Application("var") exists in vb.net I have tried: 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 window if result = system.DBNull 'DBNull' is a type...
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 populate member variables of my class. I know the...
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 bound to a DataTable object and the...
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 system.sting Thanks Robert
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.