jpvniekerk Active Member Licensed User Longtime User Sep 26, 2012 #1 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: Code: Copy 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 Code: Copy 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
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: Code: Copy 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 Code: Copy 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
P pwme Member Licensed User Longtime User Sep 26, 2012 #2 try Cursor1 = SQL1.ExecQuery2(Text, val) Could it be? Bye William Upvote 0
jpvniekerk Active Member Licensed User Longtime User Sep 26, 2012 #3 That is it! Thanks!!!!!!!!!! Now I feel just a bit stupid!! But so we learn! Upvote 0