473,412 Members | 3,471 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,412 software developers and data experts.

if result = system.dbnull

cj
in the command window I get:

? result
{System.DBNull}
[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 and cannot be used as an expression.

How can I check to see if result is equal system.dbnull in my code?
Mar 13 '06 #1
6 27290
Either of the following:

If IsDBNull(result) Then...
If result = DBNull.Value Then...

"cj" <cj@nospam.nospam> wrote in message
news:Oa**************@TK2MSFTNGP11.phx.gbl...
in the command window I get:

? result
{System.DBNull}
[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 and cannot be used as an expression.

How can I check to see if result is equal system.dbnull in my code?

Mar 13 '06 #2

"cj" <cj@nospam.nospam> wrote in message
news:Oa**************@TK2MSFTNGP11.phx.gbl...
in the command window I get:

? result
{System.DBNull}
[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 and cannot be used as an expression.

How can I check to see if result is equal system.dbnull in my code?


Perhaps this will help:

Visual Basic (Declaration)
Public Shared Function IsDBNull ( _
value As Object _
) As Boolean

Visual Basic (Usage)
Dim value As Object
Dim returnValue As Boolean

returnValue = Convert.IsDBNull(value)
--
Peter [MVP Visual Developer]
Jack of all trades, master of none.
Mar 13 '06 #3
cj
Thanks. I'll go with IsDBNull(result)

Marina Levit [MVP] wrote:
Either of the following:

If IsDBNull(result) Then...
If result = DBNull.Value Then...

"cj" <cj@nospam.nospam> wrote in message
news:Oa**************@TK2MSFTNGP11.phx.gbl...
in the command window I get:

? result
{System.DBNull}
[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 and cannot be used as an expression.

How can I check to see if result is equal system.dbnull in my code?


Mar 13 '06 #4
cj
I think I sww where you're going with this but I've already changed it
to one of Marina Levit's ideas.

Also I'm not sure how all this would fit in with, result is declared as
an object. My intention was to declare result as a string but it turns
out when there is nothing to put in it instead of it getting a null
string it gets dbnull. arrrrgh! So now result is a object and I can
check to see if it's dbnull if not it's a string. Seems to work. So
perhaps I can finish this darn program now.
pvdg42 wrote:
"cj" <cj@nospam.nospam> wrote in message
news:Oa**************@TK2MSFTNGP11.phx.gbl...
in the command window I get:

? result
{System.DBNull}
[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 and cannot be used as an expression.

How can I check to see if result is equal system.dbnull in my code?


Perhaps this will help:

Visual Basic (Declaration)
Public Shared Function IsDBNull ( _
value As Object _
) As Boolean

Visual Basic (Usage)
Dim value As Object
Dim returnValue As Boolean

returnValue = Convert.IsDBNull(value)

Mar 13 '06 #5
"cj" <cj@nospam.nospam> schrieb
in the command window I get:

? result
{System.DBNull}
[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 and cannot be used as an expression.

How can I check to see if result is equal system.dbnull in my code?


If result is DBnull.value then

Armin
Mar 13 '06 #6
"cj" <cj@nospam.nospam> schrieb:
How can I check to see if result is equal system.dbnull in my code?


'If x Is DBNull.Value Then...' or 'If IsDBNull(x) Then...'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Mar 13 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: DraguVaso | last post by:
Hi, Something I don't understand about a Typed DataSet: When a value in the DataSet is DBNull, it throws this error: "Cannot get value because it is DBNull". But aren't Typed DataSets...
4
by: Michael Culley | last post by:
Which is better: SomeValue is DBNull or SomeValue == DBNull.Value Thanks, Michael Culley
4
by: Dursun | last post by:
Hi, I am trying to assign NULL to a datetime field in the SQL Server database. Here is the code that does NOT work: INSERT INTO ... .... VALUES ... .... CType(IIf(dateWitness2Date.Checked,...
4
by: moondaddy | last post by:
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...
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
0
by: Forch | last post by:
Hi everyone, I need my UDF (which returns a table) to be able to return NULL values. My function looks like this: <SqlFunction(FillRowMethodName:="Process_TrainingInfo", TableDefinition:="...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.