program\searchfield = the field in which to search such as 'itemname'
program\searchtext = the text to search for
If the text to be found contained a "c", all items in the collumn name 'itemname' with the "c" in it are retrieved correctly.
If I type in a "ca", all items in the collumn name 'itemname' with the "ca" in it are retrieved correctly.
If I type in a "can", absolutely nothing is retrieved despite their being many occurences of words with "can" in them.
I've checked all through the Sqlite home page and the LIKE keyword is case insensitive and seems to have no arbitrary limits. Has anyone else had this problem? I cannot see what to do here.
(cannot post all source to the forum as it usually barfs when I try it)
Code: Select all
;============================================================================================================================
; Open the find inventory window
;============================================================================================================================
Procedure FindInventory()
  If EventType() = #PB_EventType_Change
  
    ClearGadgetItemList(#Gadget_inventory_items)
    
    program\searchfield = GetGadgetText(#Gadget_inventory_searchfield)
    program\searchtext  = GetGadgetText(#Gadget_inventory_searchbox)
    
    Select program\searchfield
    
      Case "all collumns"  : program\query = "SELECT * FROM inventory WHERE itemname LIKE '%" + program\searchtext + "%'"
      
        program\query + " OR  supplier LIKE '%"     + program\searchtext + "%'"
        program\query + " OR  manufacturer LIKE '%" + program\searchtext + "%'"
        program\query + " OR  modelno LIKE '%"      + program\searchtext + "%'"
        program\query + " OR  serialno LIKE '%"     + program\searchtext + "%'"
        program\query + " OR  category LIKE '%"     + program\searchtext + "%'"
        program\query + " OR  boughton LIKE '%"     + program\searchtext + "%'"
        program\query + " OR  cost LIKE '%"         + program\searchtext + "%'"
        program\query + " OR  paidby LIKE '%"       + program\searchtext + "%'"
        program\query + " OR  resale LIKE '%"       + program\searchtext + "%'"
        program\query + " OR  warranty LIKE '%"     + program\searchtext + "%'"
        program\query + " OR  location LIKE '%"     + program\searchtext + "%'"
        program\query + " OR  owner LIKE '%"        + program\searchtext + "%'"
        program\query + " OR  condition LIKE '%"    + program\searchtext + "%'"
        program\query + " OR  comment LIKE '%"      + program\searchtext + "%'"
        program\query + " OR  firstentry LIKE '%"   + program\searchtext + "%'"
        program\query + " OR  lastedit LIKE '%"     + program\searchtext + "%'"
        program\query + " OR  record LIKE '%"       + program\searchtext + "%'"
              
      Default     : program\query = "SELECT * FROM inventory WHERE " + program\searchfield + " LIKE '%" + program\searchtext + "%'"
      
    EndSelect
    If SQL3GetTable(program\query, @myRows, @myCols, program\dbhandle)
  
      program\dcounter = 0
            
      If CountList(SqlData.s()) <> 0                                              ; Check if any data was returned even if query worked
    
        ForEach SqlData.s()
          ClearStructure()
          
          inventory\itemname      = StringField(SqlData.s(),  1, "|")
          inventory\supplier      = StringField(SqlData.s(),  2, "|")
          inventory\manufacturer  = StringField(SqlData.s(),  3, "|")
          inventory\modelno       = StringField(SqlData.s(),  4, "|")
          inventory\serialno      = StringField(SqlData.s(),  5, "|")
          inventory\category      = StringField(SqlData.s(),  6, "|")
          inventory\boughton      = StringField(SqlData.s(),  7, "|")
          inventory\cost          = StringField(SqlData.s(),  8, "|")
          inventory\paidby        = StringField(SqlData.s(),  9, "|")
          inventory\resale        = StringField(SqlData.s(), 10, "|")
          inventory\warranty      = StringField(SqlData.s(), 11, "|")
          inventory\location      = StringField(SqlData.s(), 12, "|")
          inventory\owner         = StringField(SqlData.s(), 13, "|")
          inventory\condition     = StringField(SqlData.s(), 14, "|")
          inventory\picture       = StringField(SqlData.s(), 15, "|")
          inventory\comment       = StringField(SqlData.s(), 16, "|")
          inventory\firstentry    = StringField(SqlData.s(), 17, "|")
          inventory\lastedit      = StringField(SqlData.s(), 18, "|")
          inventory\record        = StringField(SqlData.s(), 19, "|")
          
          DisplayData()
          
          program\dcounter + 1
          
          LastLine(#Gadget_inventory_items, program\dcounter - 1)                   ; Make sure the current line is visible
          
         Next
        
      EndIf
      
    EndIf
    MessageHandler(#StatusBar_inventory_messages, "GetDataToStructure", "Found all records in the [ " + program\searchfield + " ] field containing the string [ " + program\searchtext + " ]", 1)
    
  EndIf
  program\query = ""
EndProcedure


