I have the next code for return a value from database
If Not IsDBNull(rsObtenerDatosNit("porteria").Value) AndAlso CBool(rsObtenerDatosNit("porteria").Value) = False Then
porteria = False
nPorteria.Checked = False
Else
porteria = True
nPorteria.Checked = True
End If
The field "porteria" in database it is bit and is with a value of 0 but does not enter to the first condition Where a checkbox with a false value is assigned if not that is entering the Else condition.
答案 0 :(得分:0)
If Not IsDBNull(rsObtenerDatosNit("porteria")) Then
If CBool(rsObtenerDatosNit("porteria").Value) = False Then
porteria = False
nPorteria.Checked = False
Else
porteria = True
nPorteria.Checked = True
End If
End If
You could even add an Else statement to the first If logic, where you show an error stating the field does not exist. But you need to be doing the IsDbNull check on the field itself, not the value of the field.