title: Using Sqlite in Qt (Qml File)
body: <p>I have the weirdest error ever using sqlite, I'm trying to connect to a database, create a table, insert some values &amp; reading them later on, Simple enough isn't it, but the weird thing is that i'm getting an error in one part of my application unlike the other part which is basically identical to the that part, for demonstration here is my first part which is working just fine:</p>
  
  <pre><code>Rectangle{
          id:enterYourName
  
  function getDatabase() {
       return LocalStorage.openDatabaseSync("HomeScreen", "1.0", "StorageDatabase", 100000);
  }
  
  
  function initialize() {
      var db = getDatabase();
      db.transaction(
          function(tx) {                                                         
  
              tx.executeSql("CREATE TABLE IF NOT EXISTS settings (setting TEXT UNIQUE, value TEXT)");
        });
  }
  
  
  function setSetting() {
     var db = getDatabase();
     db.transaction(function(tx) {
  
                     var rs = tx.executeSql("INSERT OR REPLACE INTO settings VALUES (?,?);", ['myName',mytextInput.text]);
  
          }
    );
  }
  
  
  
  
  function getSetting() {
     var db = getDatabase();
     var res="";
     db.transaction(function(tx) {
         var rs = tx.executeSql('SELECT value FROM settings WHERE setting=?;', ['myName']);
  
       if (rs.rows.length &gt; 0) {
            res = rs.rows.item(0).value;
       } else {
           res = "Unknown";
       }
    })
  
    return res;
  }
  
  
  
  
   TextInput{
              id:mytextInput
              anchors.centerIn: parent
              text:enterYourName.getSetting()
              maximumLength: 12
              font.family: harlow_Font.name
              font.pixelSize: 0.029*windowid.width
              visible: true
          }
  
  }
  </code></pre>
  
  <p>&amp; here is the second part, In the second part im doing exactly the same thing as above but i'm getting an error saying: <code>Unable to assign [undefined] to QString</code> when the line <code>enterYourName2.getRedValue()</code> located in TextInput is executed</p>
  
  <pre><code>Rectangle{
          id:enterYourName2
  
   function getDatabase() {
               return LocalStorage.openDatabaseSync("SecondHome", "1.0", "StorageDatabase", 100000);
          }
  
  
          function initialize() {
              var db = enterYourName2.getDatabase();
              db.transaction(
                  function(tx) {
                      tx.executeSql("CREATE TABLE IF NOT EXISTS mytable (redp TEXT UNIQUE, redvalue TEXT)");
  
                });
          }
  
  
  
          function setRedValue() {
             var db = enterYourName2.getDatabase();
             db.transaction(function(tx) {            
                             var rs = tx.executeSql("INSERT OR REPLACE INTO mytable VALUES (?,?);", ['myName2',mytextInput2.text]);
  
                  }
            );
          }
  
  
  
          function getRedValue() {
             var db = enterYourName2.getDatabase();
             var res="";
             db.transaction(function(tx) {
                 var rs = tx.executeSql('SELECT redvalue FROM mytable WHERE redp=?;', ['myName2']);
  
               if (rs.rows.length &gt; 0) {
                    res = rs.rows.item(0).value;
               } else {
                   res = "Unknown";
               }
            })
  
            return res;
          }
  
  
  
          Component.onCompleted: enterYourName2.initialize()
  
  
  
  
   TextInput{
              id:mytextInput2
              anchors.centerIn: parent
              text:enterYourName2.getRedValue()  //The Error is raised over here
              maximumLength: 12
              font.family: harlow_Font.name
              font.pixelSize: 0.029*windowid.width
              visible: true
          }
  
  }
  </code></pre>
  
  <p>Any ideas on why this error appeared &amp; how it can be resolved?</p>