Ricky D Well-Known Member Licensed User Longtime User Jan 24, 2012 #1 How do we handle saving & retrieving boolean values from an sqlite database? I am assuming I have to declare the type as DB_INTEGER What does sqlite expect for true and false? Is there any code I can see? regards, Ricky
How do we handle saving & retrieving boolean values from an sqlite database? I am assuming I have to declare the type as DB_INTEGER What does sqlite expect for true and false? Is there any code I can see? regards, Ricky
NJDude Expert Licensed User Longtime User Jan 24, 2012 #2 In SQLite you can define the field as BOOLEAN and can be retrieved using Cursor1.GetString("BooleanField") Upvote 0
In SQLite you can define the field as BOOLEAN and can be retrieved using Cursor1.GetString("BooleanField")
Ricky D Well-Known Member Licensed User Longtime User Jan 24, 2012 #3 sqlite on android doesn't have that sqlite on android only has BLOB, INTEGER, REAL & TEXT according to dbutils I created my db using dbutils. I couldn't create one outside B4A that would work. regards, Ricky Upvote 0
sqlite on android doesn't have that sqlite on android only has BLOB, INTEGER, REAL & TEXT according to dbutils I created my db using dbutils. I couldn't create one outside B4A that would work. regards, Ricky
warwound Expert Licensed User Longtime User Jan 25, 2012 #4 I've done this by using a column with an INTEGER data type. I store a 0 for False and a 1 for True. Then in my B4A code i do something like this: Code: Dim IntegerToBoolean() As Boolean IntegerToBoolean=Array As Boolean(False, True) ' to get a Boolean value from the query: MyBoolean=IntegerToBoolean(Cursor1.GetInt("TheIntegerColumnName")) Martin. Upvote 0
I've done this by using a column with an INTEGER data type. I store a 0 for False and a 1 for True. Then in my B4A code i do something like this: Code: Dim IntegerToBoolean() As Boolean IntegerToBoolean=Array As Boolean(False, True) ' to get a Boolean value from the query: MyBoolean=IntegerToBoolean(Cursor1.GetInt("TheIntegerColumnName")) Martin.
Ricky D Well-Known Member Licensed User Longtime User Jan 25, 2012 #5 That should work! :sign0142: Thanks Martin. cheers, Ricky Upvote 0
AHilberink Well-Known Member Licensed User Longtime User Jul 7, 2014 #6 Hi, Is there also an easy way to convert a Boolean to an Int for saving in SQLite or do I have to build If...Then for every Checkbox? Best regards, André Upvote 0
Hi, Is there also an easy way to convert a Boolean to an Int for saving in SQLite or do I have to build If...Then for every Checkbox? Best regards, André
AHilberink Well-Known Member Licensed User Longtime User Jul 7, 2014 #7 Hi, I already figure it out. I use: Code: Sub BooleanToInt(Check As Boolean) As Int If (Check) Then Return 1 Else Return 0 End If End Sub Best regards, André Upvote 0
Hi, I already figure it out. I use: Code: Sub BooleanToInt(Check As Boolean) As Int If (Check) Then Return 1 Else Return 0 End If End Sub Best regards, André