Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Visual Basic (http://www.programmingforums.org/forum18.html)
-   -   Null<>Null? (http://www.programmingforums.org/showthread.php?t=8412)

Mythrandil Feb 15th, 2006 3:58 AM

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

DaWei Feb 15th, 2006 7:09 AM

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?

Mythrandil Feb 15th, 2006 8:01 AM

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 :)

DaWei Feb 15th, 2006 8:09 AM

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.


All times are GMT -5. The time now is 7:40 PM.

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