itnifl
asked on
VB .Net - Boolean Values in Access database
How do I handle boolean values in a access database? I want ionvert the value of what exists in the database. If the value is false in the cell, I want to make it true. And the other way around. I was thinking something like below:
Dim assetRow As dataset.assetRow
assetRow = Dataset.assetRow.FindByassetnr(assetNr)
If IsDBNull(assetRow.active) Then
With assetRow
.BeginEdit()
.active = true
.EndEdit()
End With
End If
If assetRow.active = True Then
With assetRow
.BeginEdit()
.active = false
.EndEdit()
End With
Else
With assetRow
.BeginEdit()
.active = true
.EndEdit()
End With
End If
End If
Dataadapter.Update(Dataset.GetChanges())
ASKER
No, not yet, but shouldnt it be ok to use false and true?
You can also use the actual values: 0 for false and 1 for true.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yeah the allignment of the values are ok, but the problem now is that the changes dont get stored to the database. The are updated in the grid, but they are never stored to the database. I thought Dataadapter.Update(Dataset .GetChange s()) followed by Dataset.AcceptChanges() would do that. Any ideas?
>>No, not yet, but shouldnt it be ok to use false and true?<<
Yes.
>>You can also use the actual values: 0 for false and 1 for true.<<
I suspect you mean 0 and -1
Yes.
>>You can also use the actual values: 0 for false and 1 for true.<<
I suspect you mean 0 and -1
ASKER
I never actually fixed the error where the values didnt get stored in the database, but they did get inverted in the dataset and datagrid.
.active = Not .active