equivalent of bit data type in C#


Question: How do you define a bit T-SQL data type in C#? What is the equivalent of a SQL bit data type in C#?


Login to See the Rest of the Answer

Answer:
When you define a column data type to bit which has a value of 0 or 1, you can declare Property in C# to represent the bit data type defined in SQL Database as a bool (bolean). Bolean presents a bit data type in SQL and if you are wondering what value represents or maps to 0 or 1 bit in SQL Server Database see below:

Steps:

1. Create a column with a name "Active" in the Database table with a Data Type of "bit"
2. Scroll down under "Column Properties" and fill the text box with a label "Default Value or Binding". The value should be 1 for "Active" and 0 for "Not Active".
3. In short 1 bit data type maps to true (bolean value in c#) as for 0 bit maps to false in C#.

If this did not solve your problem see another article here.






© 2024 - ErnesTech - Privacy
E-Commerce Return Policy