![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Feb 2006
Posts: 2
Rep Power: 0
![]() |
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 |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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 |
|
|
|
|
|
#3 | |
|
Newbie
Join Date: Feb 2006
Posts: 2
Rep Power: 0
![]() |
Quote:
the IsNull function sorted my problem though thanks ![]() |
|
|
|
|
|
|
#4 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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 |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|