Saving a check in SQL - Ana

30-Nov-06 01:40:23
Hi,
When saving a check from a form into a SQL table (having a field as int), it
is stored as -1 instead of 1.
What's the workaround?
TIA
Ana

--------------------------------------------------------------------------------
Estoy utilizando la versión gratuita de SPAMfighter para usuarios privados.
Ha eliminado 461 correos spam hasta la fecha.
Los abonados no tienen este mensaje en sus correos.
¡Pruebe SPAMfighter gratis ya!
button
 
 

Saving a check in SQL - ckelly

06-Dec-06 08:16:08
Ana,

A check-box is a Boolean value - i.e. TRUE or FALSE. (Most?) Databases store
Boolean values as Integers, setting all Bits to 0's for a FALSE value (Hex:
0x00) & all Bits to 1's for a TRUE value (Hex: 0xFF). An integer with all its
Bits set to 1's has an integer value of -1. An integer with value=1 has a hex
representation of 0x01 - i.e. only 1 TRUE Bit in 16.

I'm not too sure I've explained this well, but If this doesn't make too much
sense, then you _really_ need to learn some Hexadecimal basics and how +ve & -
ve integer values are represented.
button
 

Saving a check in SQL - Robert Morley

06-Dec-06 11:54:12
Following up on ckelly's reply, you should probably just change the "int" to
a "bit" field in SQL Server.  If you have a good reason not to do that, then
you'll have to use an unbound field for your check-box filling it manually
when you move to a new record, and changing the value manually every time
someone clicks in it.


Rob
button
 
d