if result = system.dbnull

  • Thread starter Thread starter cj
  • Start date Start date
C

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?
 
Either of the following:

If IsDBNull(result) Then...
If result = DBNull.Value Then...
 
cj said:
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)
 
cj said:
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
 
Thanks. I'll go with IsDBNull(result)
Either of the following:

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

cj said:
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?
 
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.

cj said:
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)
 
Back
Top