Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 15th, 2006, 3:58 AM   #1
Mythrandil
Newbie
 
Join Date: Feb 2006
Posts: 2
Rep Power: 0 Mythrandil is on a distinguished road
Null<>Null?

hey

maybe im being stupid here but its been awhile since i did a database frontend. Im using vb6 and mysql db.

One of my fields in database can be null and is set to be as default, sometimes i need to check this so i have a simple statement

if rs!date_in = Null then ...

However this appears to never be true during runtime, a debug shows that rs!date_in is in fact null but vb beleives it still doesnt warrant executing the if statement lol.

Anyways what im asking is vb's null different to mysql? and how would you get around this problem considering the field has to able to be null and i have to know when it is?

p.s. i tried setting a default value of 0000-00-00 00:00:00 (datetime standard) however the ql still returns this as null! >.<

Thanks in advance
Mythrandil is offline   Reply With Quote
Old Feb 15th, 2006, 7:09 AM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
This is not definitive help, but I've had difficulties reconciling NULL values from time to time. If you try to store NULL into a MySQL column that doesn't accept NULL, you will store a zero or "". MySQL has an IFNULL (a, b) and an ISNULL function which you might use to constrain the value returned to your code. VB has IsNull (). You should probably use these kinds of tests as NULL (as well as NaN) is treated differently by many languages. Sorry I can't give you any truly solid solution. Incidentally, I think the date field being zero vs NULL was changed at some version level. Crap like that always helps, right?
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Feb 15th, 2006, 8:01 AM   #3
Mythrandil
Newbie
 
Join Date: Feb 2006
Posts: 2
Rep Power: 0 Mythrandil is on a distinguished road
Quote:
Originally Posted by DaWei
This is not definitive help, but I've had difficulties reconciling NULL values from time to time. If you try to store NULL into a MySQL column that doesn't accept NULL, you will store a zero or "". MySQL has an IFNULL (a, b) and an ISNULL function which you might use to constrain the value returned to your code. VB has IsNull (). You should probably use these kinds of tests as NULL (as well as NaN) is treated differently by many languages. Sorry I can't give you any truly solid solution. Incidentally, I think the date field being zero vs NULL was changed at some version level. Crap like that always helps, right?
the field was deffintely null as i checked using mysql query browser.

the IsNull function sorted my problem though thanks
Mythrandil is offline   Reply With Quote
Old Feb 15th, 2006, 8:09 AM   #4
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Glad I could give you some investigative paths, because there's no widespread approach. In some languages, if (null == null) will return false (the theory being that null isn't equal to anything), and that kinda sucks.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:13 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC