Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

A SQL Server database stores a bit value as 1 or 0.

Visual Basic stores true false as -1 and 0.

 

As far as I can tell every time you read a bit column you are going to have to multiple it by -1 in order to test for true/false in VB?

 

Did I get this right or is there an easier way (without storing the value as an integer in sql server) ?

 

Thanks,

Patrick

Posted

I've got a feeling that Vb treats anything other than a 0 as true (though i might be thinking of something else) which means there would be no problem.

Logic wise if you want to test for true use something along lines of Not(Value =false)

As false is the same in both cases and and will return true for either 1 or -1.

Afraits

"The avalanche has started, it is too late for the pebbles to vote"

Posted

(assuming the value is stored as a Signed Byte)

 

 

False = 0

True = "NOT" False:

 

False = 0000 (in binary)

True = NOT 0000 (in binary) = 1111

 

Using Two's complement, 1111 = (-1)

 

so, True = -1

 

HOWEVER...

 

VB.net will recognise anything that is "not" false as being true!

 

B.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...