ExecQuery2 and variable size array

jpvniekerk

Active Member
Licensed User
Longtime User
I am trying to develop a (complex) filter system for a database (SQLite) in one of my programs.
I am having problems setting this up as the array must be of a variable size (variable number of items in the array)

I am trying the following:
B4X:
Dim Text as String
Text = "SELECT * FROM Table WHERE Field1=? AND Field2=? AND (Field3=? OR Field3=? OR Field3 =?) AND Field4 = ?"

Dim Val(6) as String   ' The number (6) may be different for certain queries

Val(0) = Value1     'Defined as string and set earlier in program
Val(1) = Value2     'Defined as string and set earlier in program
Val(2) = Value3     'Defined as string and set earlier in program
Val(3) = Value4     'Defined as string and set earlier in program
Val(4) = Value5     'Defined as string and set earlier in program
Val(5) = Value6     'Defined as string and set earlier in program

Cursor1 = SQL1.ExecQuery2(Text, Array as String(val))

I don't get any errors - it runs fine, but returns 0 records (even if it should, based on the values)

Changing the last line as follows gives me the right results
B4X:
Cursor1 = SQL1.ExecQuery2(Text, Array as String(value1,value2,value3,value4,value5,value6))
... but this does not help if the number of variables change.

Any help for a solution will be GREATLY appreciated
 
Top