Bit Datatype

M

Miro

I created a table with a bit datatype column.
I created this column as "do not allow null" and default value of 0

Now when I go into the Database explorer, right click on the table and click
on "show table data",
to manually add some of my own data into it. How do I actaully type in a
value on the bit field?

The only thing that is saving me is that the default value is there. But I
cant seem to type in a value,
either 0, 1 True / False Yes No .

It keeps giving me the same error,
Invalid Value for cell ( row 2, column 6 )

The changed value in this cell was not recognized as valid.
..Net Framework data Type: Boolean
Error Message: String was not recognized as a valid boolean.
Type a value appropriate for the data type or press ESC t ocancel the
change.

I cant quite figure out how to type in a value here.
I can make a form with a datagrid - then I have a checkbox so I can enter
data that way. But its annoying me I cant figure out how to do this here.

Thanks

Miro
 
M

Mark S. Milley, MCSD (BinarySwitch)

Hi Miro -

True and False as values work on my end. Really, the values are stored
as -1 and 0 respectively.

Try putting in some data into all the other columns first (at least,
any that can't be null and don't have a default value). Then refresh
the table, and see how your interface is reporting the False value
that should be inserted on the DB side. After that, you should be able
to determine what to use for True (whatever the syntactic antonym is).

By the way, what are you using for a database? MS SQL Server 2005?

Cheers,

-Mark
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Miro said:
I created a table with a bit datatype column.
I created this column as "do not allow null" and default value of 0

What database are you using?

The BIT data type according to the SQL92 standard is a string type, but
most databases implement it differently, like a numeric value or an
enumerated value.
Now when I go into the Database explorer, right click on the table and click

What database explorer are you using?
 
M

Miro

Its SQL Express 2005

Ok - at least now I know I wasnt going crazy and "True" - "False" does work.

I deleted the table - re-created it without any joins and it worked.

I suspect I know what I did. - all user error and i should have rtfs when i
did a relationship.
I have another table called Login with a key LoginID - no nulls

here is a notes table so the keys are
NoteID - no nulls
LoginID - allow nulls here

I am suspecting the error was not actually an error on the boolean/bit field
but an error wth a wrong relationship.
It looks like the error is with the Bit field - but the bit field is my last
field in my whole table.

The only way I can re-create the error is doing a stupid relationship to
LoginID with NotID instead of Note-LoginID.
When you get to the last field ( in this case the bool field ) it errors
out -but not because of the field - because it cant join up the tables.

Thanks for your help.
-Super hard googling for key words like "bit" / "boolean" / "yes" / "no"
"VB.net" "datatype"

And back to learning...

Miro
 
C

Cor Ligthert [MVP]

Miro,

The normal values for a bit type in SQL are, at least by the last two
managers for i,t forever 0 and 1.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top