SQL logic error or missing database

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • RizlaUK
    Indigo Rose Customer
    • May 2006
    • 5478

    SQL logic error or missing database

    Hi Guys, im getting this werid thing going on

    if my app loses focus at startup i get the "SQL logic error or missing database" but the werid thing is when i close the error dialog i can access all the tables on the database with no errors

    like in say, it only happens when the app loses focus at startup

    any ideas ?
    Embrace change in your life, you never know, it could all work out for the best
  • azmanar
    Indigo Rose Customer
    • Oct 2004
    • 1020

    #2
    Hi,

    3 main reasons when I have "SQL logic error or missing database" errors:
    1. The Column Names you're referring to using SQL statements DIFFERS from the Column Names existing in the DB file itself
    2. The Column Name SEQUENCE you're inserting/updating to using SQL statements DIFFERS from the Column Name SEQUENCE existing in the DBfile itself
    3. Differing DB names or Table names in the SQL Statement against what have been set in the DB file.
    Newbie Examples
    ------> AMS 7.5 : amstudio.azman.info
    ----> AMS 6 & 5: www.azman.info/ams/
    ----> FB: facebook.com/GuideToWealth

    ----> Content Development Blog: www.AZMAN.asia

    Comment

    • RizlaUK
      Indigo Rose Customer
      • May 2006
      • 5478

      #3
      Thats the thing, iv check, double checked, triple checked, took a break and triple checked everything again and all is right

      But....., iv managed to track it to a a particular function that is called in the main page onshow event

      PHP Code:
      function reload()
      ComboBox.ResetContent("ComboCats");
      local tbReturn SQLite.QueryToTable(db"Select * from sqlite_master where type = 'table' ORDER BY name");
      error Application.GetLastError();
      if (
      error ~= 0then
          Dialog
      .Message("Error"_tblErrorMessages[error], MB_OKMB_ICONEXCLAMATION);
      end
          
      if tbReturn and tbReturn.Rows 0 then
              
      for i,v in tbReturn.Data do
              
      result ComboBox.AddItem("ComboCats"tbReturn.Data[i]["name"]);
              
      end
          
          end
      end 
      the database is opend in the action >>startup event and works fine (as do all the database functions) but when (and only when) i launch the app and imeaditly click another open window causeing the app to lose focus it will give the error

      but.....this function works even though its saying "SQL logic error or missing database" the database is there and all the tables show up in the combobox as intended

      this has me stumped BIG TIME,
      Embrace change in your life, you never know, it could all work out for the best

      Comment

      • TJ_Tigger
        Indigo Rose Customer
        • Sep 2002
        • 3159

        #4
        I wonder if the SQLite plugin is not able to open the database and assign it to the application when you switch focus. Try adding some code into your function that checks to see if db is valid or not. It obviously gets set if you don't switch to another app during startup. Maybe build a function for opening your database.

        function OpenDB()
        return SQLite.Open("path\\to\\db");
        end

        Then add this to your reload function

        Code:
        function reload() 
        ComboBox.ResetContent("ComboCats"); 
        if not db then db = OpenDB(); end
        --if the db is large maybe add an application.sleep here to have it wait for a moment before querying.
        local tbReturn = SQLite.QueryToTable(db, "Select * from sqlite_master where type = 'table' ORDER BY name"); 
        error = Application.GetLastError(); 
        if (error ~= 0) then 
            Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION); 
        end 
            if tbReturn and tbReturn.Rows > 0 then 
                for i,v in tbReturn.Data do 
                result = ComboBox.AddItem("ComboCats", tbReturn.Data[i]["name"]); 
                end 
             
            end 
        end
        TJ-Tigger
        "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
        "Draco dormiens nunquam titillandus."
        Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

        Comment

        • RizlaUK
          Indigo Rose Customer
          • May 2006
          • 5478

          #5
          Hey, thanks for the suggestion tigg, but it dident work

          but this is getting stranger and stranger,

          i tought id try like this

          if not db then
          db = OpenDB();
          Application.Sleep(2000);
          reload();
          else
          reload();
          end

          and it still gives the error, so i tryed this

          if not db then
          db = OpenDB();
          Application.Sleep(2000);
          reload();
          end

          there was no error but the function dident fire, and b4 this bit of code i have the OpenDB() function fireing twice just to make sure its open,

          so, iv added a splash page with the this in the page onshow

          Application.Sleep(5000);
          OpenDB();
          Page.Jump("code");

          and if the window isent in focus i still get the error

          i think you are right ie: "the SQLite plugin is not able to open the database and assign it to the application when you switch focus"

          and it seems that no matter what i do i cannot get around it, the app window has to be active for the sqlite plugin to work
          Embrace change in your life, you never know, it could all work out for the best

          Comment

          • RizlaUK
            Indigo Rose Customer
            • May 2006
            • 5478

            #6
            ok, iv been going over and over this for hours, iv tested and retested,

            its only a call to the database that calls the "sqlite_master" table, any other function works weather the page is in focus or not

            so just a lil heads up, dont call the sqlite_master table on a start up or page show event, the page must be in focus to access the sqlite_master table,

            i worked round my problem by calling the function in the combobox onfocus event and it all works fine now
            Embrace change in your life, you never know, it could all work out for the best

            Comment

            Working...
            X