Link to home
Start Free TrialLog in
Avatar of itnifl
itniflFlag for Norway

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())

Open in new window

Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Have you tried:

.active = Not .active

Avatar of itnifl

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
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of itnifl

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.GetChanges()) 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
Avatar of itnifl

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.