I'm designing a SQL datbase table and a couple of the columns need to hold either a 1 or 0 (true or false). I define the columns to be of type binary(1), but now I don't know how to insert a true or false value into the database. inserting "true" or "1" doesn't work (it says either int or bool cannot be converted to binary)...
Use the bit
data type instead for your column. Then you can insert true/false directly.
Use bit
This accepts the strings "true" and "false".
It also maps directly to the c# boolean type which is useful
由于SQL Server中没有布尔值,因此您可以使用bit
并将其设置为0/1
This depends on what database you are using. Eg, for SQL Server you can use bit and then set it to true using an integer 1. For Access, you can use a boolean and set it to True/False.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.