vendredi 2 juin 2017

Setting CheckBox.Checked state to True - "Input String was not in Correct Format"

I'm saving a boolean variable in an MS-Access database, (although interestingly, as I added it programmatically, it's showing in the DB as 0 or -1, rather than a tickbox?), and when loading in the data into a form, I have the following code:

cbNoCharge.Checked = Convert.ToBoolean(fTable.Rows(0).Item("freeDelivery"))

However, this is erroring, saying

Input string was not in a correct format

This is confusing me? Despite the initial DB value being a boolean anyway, I'm then converting it to one just to make sure of it. Why is a value of 'True' or 'False' not working as a boolean?

I also tried it as

If fTable.Rows(0).Item("freeDelivery") = True Then
    cbNoCharge.Checked = True
End If

But the same thing happened? What on Earth is going on?!




Aucun commentaire:

Enregistrer un commentaire