Cast DBNULL problems

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi! I have a problems with DBNULLs
I have a date field and couple of other fields, when I save my data, if it was a null when I got the data I want to keep that data intact even if it was a DBNULL
Little example
function savedata(DateFinish as date,Room as string...etc.

savedata(cdate(DatePicker.value,txtRoom.text
If the Date is DBNULL I will have an error Cast DBNULL to date type is invalid

I'm a new in the .NET world, Thanks Joel :)
 
If IsDBNull(value) then
handle the null value
Else
handle the data
End If


Joel said:
Hi! I have a problems with DBNULLs.
I have a date field and couple of other fields, when I save my data, if it
was a null when I got the data I want to keep that data intact even if it
was a DBNULL.
 
I know I can do that but I don't want to change the DBNULL value to
something. I want to send back a null value to the DB, if I originally
receive it like that.
A good exmaple is a Finish date, if the work is not finish the User will
receive the date as a null and that don't mean he will change it.

Thanks Joel :)
 
I think you might be looking for:

SqlDateTime.Null

"Represents a null value that can be assigned to the Value property of an
instance of the SqlDateTime structure."

Regards

Shane Brodie
 
My example will not change the data in the DB if it is null.

You can write the statement another way:

If Not IsDBNull(value) then
handle the data
End If

If there is a null value you won't do anything with it.
 
Thanks I will check this out. Joel :)
Shane Brodie said:
I think you might be looking for:

SqlDateTime.Null

"Represents a null value that can be assigned to the Value property of an
instance of the SqlDateTime structure."

Regards

Shane Brodie
 
Back
Top