user838359 user838359 - 1 month ago 8
C# Question

Store check box value as bit in DB

Hi i have a checkbox and in code behind i insert the value from checkbox into the DB. This is what i did:

ClassRegInfo order1 = new ClassRegInfo
{
classID = classID.Text,
ObtainedPermission = Convert.ToByte(obtainedPermission.Checked)}


Obtained Permission in DB is of type bit. So when I do the above step, i get an error:

Cannot implicitly convert type byte to bool


So, can u let me know how to store the value as a bit in DB?

Answer

Dont convert it to byte. Bit equals Bool

ClassRegInfo order1 = new ClassRegInfo
{
        classID = classID.Text,
        ObtainedPermission = obtainedPermission.Checked
}