Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OLEDB JET and NULL value for Boolean Type

I have to move data from an old application written in Delphi/BDE (DBase IV) to a new one using VisualStudio 2008/SQLServer. I'm fairly new to VS. To connect to the dbase tables from visual Studio, i use OLEDB JET 4.0 and I'm having troubles querying my table against boolean values.

Let's say my table contains an integer and a boolean field (or Logical field ?)

1 true
2 NULL
3 false

SELECT * from mytable will display in the bottom grid of visual studio

1 true
2 false
3 false

NULL seems to default to false (BDE used to do the same), which is fine by me. I think NULL values for a boolean field don't make sens anyway. But then

SELECT * from mytable where field2 IS NOT NULL displays the same result

SELECT * from mytable where field2 IS NULL displays an empty resultset

and the best :

SELECT * from mytable where field2 = true will display in the bottom grid

1 true
2 false

so the question is : do NULL values for boolean type default to true ? (and the grid is just misbehaving by displaying them as "false"?) or does is default to false ? in which case my oledb dll might be outdated or buggy (why not) ?

like image 484
user2956710 Avatar asked Nov 19 '25 14:11

user2956710


1 Answers

I'm not excatly answering my own question but some progress has been made since i asked it.
I've been trying different versions of msjet40.dll and MSJETOLEDB40.dll.
In the original post, I used :

Windows 8.1 + Visual Studio 2008 SP1,
MSJETOLEDB40.dll 4.0.9756.0
MSJET40.dll 4.0.9765.0

(and before you ask, there is no typing mistake : it is 9765, not 9756 for MSJET40, I've checked twice).
The results were the one's described in the first post, that is : NULL boolean values seems to default to True but grid displays false and IS NULL doesn't see the NULL values. I then tried :

Windows XP SP3 + visual Studio 2008 (with and without SP1).
MSJETOLEDB40.dll 4.0.9502.0
MSJET40.dll 4.0.9511.0

The results are slightly better (more consistent anyway): boolean NULL defaults to true and the Grid does indeed display "true" (instead of false in the windows 8.1 setup). But IS NULL still doesn't see the NULL values. Eventually I tried :

Windows 7 SP1 + Visual Studio 2008 (with and without SP1),
MSJETOLEDB40.dll 4.0.9756.0
MSJET40.dll 4.0.9756.0

Ah... Nice (at last !) : boolean NULL defaults to false and the Grid does indeed display "false". As for IS NULL, still doesn't see the NULL values but considering it defaults to false, I don't mind that anymore.

To answer Oleg question, Connection strings were the same in the 5 tests I've made :

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Cartociel\Descamps;Persist Security Info=False;Extended Properties="dBase IV"
For now, unless someone has a better idea, I suspect MSJET40 4.0.9765 is the culprit and I'll see if an older version of that dll could work on my windows 8.1 setup.

sorry for that long Post (and still working on it)...

like image 92
user2956710 Avatar answered Nov 22 '25 06:11

user2956710



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!