2

Bit columns store a 1 or a 0.

Entering 1 or 0 in a bit column gives the ERROR:

Invalid value for cell (row 42, column 17).

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 to cancel the change.

How can 1 or 0 NOT be a valid boolean?

Bit fields should allow 1 or 0.

4
  • To answer your question How can 1 or 0 NOT be a valid boolean? - pretty easily, 1 or 0 are integers, try this in c# for example: bool b = 1;, it won't even compile. To solve your problem you will probably need to post more information. Commented Jul 18, 2014 at 10:42
  • when i tried to insert 0 or 1 in a boolean value in sql server 2008. it wont inserted it will throw the error.. instead tat you have the enter true as 1 and false as 0 Commented Jul 18, 2014 at 10:51
  • SQL Server does not have a boolean datatype, it has BIT which allows 1 or 0. Your error (as indicated by the message) is coming from the .NET framework, where you can't convert 1 or 0 to a boolean. Commented Jul 18, 2014 at 10:55
  • Then what's the point of bool.Parse? Isn't the whole purpose of parse to take something in a different format and convert it? Commented Apr 8, 2020 at 16:00

1 Answer 1

3

Yeah i encountered this problem a lot, when i tried to insert 0 or 1 in a boolean value in sql server 2008...

To fix it, i used BIT type as a boolean type: The BIT Type takes 2 values:

If you want to insert 0 then you have to type "False" value else if you want to insert 1 then you have to type "True" value

then if you want to use BIT value as int then use CAST(BITFIELD as int) it will convert it to 0 or 1

I hope it helped...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.