0 Replies Latest reply on Nov 25, 2009 3:23 AM by gauravgr8

    Flex AIR Sqlite as embedded database

    gauravgr8 Level 1

      Hi all,

      I am devloping an editor with spell check feature in Flex + AIR using Sqlite as an embedded database.
      In database I have a table with the words. The table contains lacs of words. I have written the code to search for the word in table. I have used the sync method for all this. This pauses my application while searching.
      I would like to use async method to stop application pause.

      The code for Search word is as follows:
          public function searchInDictionary(word:String):Boolean
          {
         if(word == "")
          return true;
            connection= new SQLConnection();
            var query:SQLStatement = new SQLStatement();
            query.sqlConnection = connection;
            query.text = 'SELECT id FROM tbl_'+ CommonLanguageCode +' WHERE word LIKE "'+word+'"';     
          
            try
            {       
              connection.open( dbfile,SQLMode.READ );
            }
            catch(ex:Error)
            {}
       
            if(!connection.connected)
              connection.open( dbfile );
            query.execute();
            var result:SQLResult = query.getResult();
            if( result.data == null )
            {
              return false;
            }
            else
            {
              var numRows:uint = result.data.length;
              var id:String;
              if(numRows>0)
                return true;
              return false;
            }
            return false;       
        }

      If this function returns false(word not found) then i have to call the function to to red underline that word.

       

      Please suggest me if I am going wrong. As I am using Sync method & it takes some milli seconds to search a word. & if I am wrting a paragraph then it makes my application sluggish.

      Is there any other way I can store the words & search more fastly. If yes then please et me know.

       

      Thanks in advance.