In .NET, a Boolean on a 32 bit operating system takes up 4 bytes. On a 64 bit operating system it takes up 8 bytes.
A
True
Boolean value means that every bit in the 4 or 8 Bytes allocated to the Boolean is set to
1
.
The first bit position in a signed integer represents if the integer is positive or negative.
So, if every bit is set to
1
this means that the value is negative.
Which explains why a Boolean
True
becomes
-1
when you cast it into an Integer in VB.NET
When you are planning on storing a Boolean into a MS SQL Server Database, you indicate that the column should be a "Bit" type. In MS SQL Server,
1
represents true and
0
represents false.
Obviously this is a different data type than the 4/8 Byte .NET Boolean that your VB.NET application uses. This is why .NET has built in tools that automatically convert database data types to .NET data types when storing and retrieving the data.
I have not personally connected to an Oracle database with .NET code before so I took a look at the documentation for the
OracleDataReader class and discovered that it has a
GetBoolean method that you should probably consider using.
-Frinny