473,467 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Vb.net Oracle Boolean database numeric value 1

1 New Member
Hi,
Vb.net boolean True is representing -1 , this code work for Ms Access, Ms SQL ect. But not work Oracle, because Oracle true is setting 1 in database (not -1)

Expand|Select|Wrap|Line Numbers
  1. oRow("CAT_SELECTED") = True
  2. If oRow("CAT_SELECTED") = True Then
  3.     ' Not True
  4. End If

I found this information about <OracleBoolean Structure> http://msdn.microsoft.com/en-us/libr...v=vs.110).aspx
But I need a sample change for true 1 to -1 for oracle. Thanks for all helps...
Nov 27 '13 #1

✓ answered by Frinavale

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

1 2135
Frinavale
9,735 Recognized Expert Moderator Expert
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
Dec 2 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Iona | last post by:
okay.. this should be long.. I made up a table in database with access consists of columns with text type. Some of them I put in data with numeric value and some of them I put in "Unlimited" as...
1
by: Luigi Ida' via SQLMonster.com | last post by:
Hi, I have a php application connected through odbc to a sqlserver database. When I try to execute select queries on a smalldatetime table field I receive this message: Warning: Numeric value...
4
by: vighnesh | last post by:
Hi All I am presently dealing with a project,in which I have to convert an XLS file into XML file. To accomplish this I have used Dataset as intermediatory to store the data from XLS and...
3
by: Adotek | last post by:
Hi All, I am getting this error: Microsoft OLE DB Provider for ODBC Drivers error '80004005' Numeric value out of range (null) /database/data_entry.asp, line 90 Line 90 is shown below...
13
by: nishit.gupta | last post by:
Is their any fuction available in C++ that can determine that a string contains a numeric value. The value cabn be in hex, int, float. i.e. "1256" , "123.566" , "0xffff" Thnx
0
by: takveen | last post by:
The Topics Covered In This Book Are: Understanding the Oracle Environment; Understanding the Oracle Instance; Understanding the working of Oracle Instance; Understanding the Oracle Database; Oracle...
1
by: takveen | last post by:
The Topics Covered In This Book Are: Understanding the Oracle Environment; Understanding the Oracle Instance; Understanding the working of Oracle Instance; Understanding the Oracle Database; Oracle...
2
by: tron_23 | last post by:
hi, we use Toplink (TopLink - 4.6.0 (Build 417) with a DB2 Database 7.2. i know really old versions, but we could change to e newer one ;-) Sometimes we got some problems with update or insert...
4
by: Serman D. | last post by:
I would like to extract the first 6 digits of a numeric value (e.g. the string '123456' out of the numeric 1234567890123456789). I tried a combination of CAST and SUBSTR, but it seems I am not...
13
by: NSkram79 | last post by:
I have a database that I created for logging Calls for Service for a Security Department I work for. In that database it logs the Date of Entry and Time of Entry . For statistical purposes I...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.