1 Reply Latest reply: Apr 12, 2012 1:12 AM by _spoboyle RSS

    Flash builder + sqlight error #3115

    Epictom123

      Hi guys i'm making a mobile app with flash builder but i stumble upon an error. In short terms, you put a text in a text input, u click a button and it only lists the things from the database with that imputted text in it. Here are the codes:

      '

      First the Homeview.mxml:

      <?xml version="1.0" encoding="utf-8"?>
      <s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
        xmlns:s="library://ns.adobe.com/flex/spark" title="Home"
        xmlns:dao="dao.*">
        <fx:Declarations>
        <dao:RoosterDAO id="srv"/>
        </fx:Declarations>
      
      
        <s:Label x="11" y="6" fontSize="36" text="Klas:"/>
        <s:TextInput id="Klas" x="91" y="6" width="262" height="30"/>
        <s:Button id="btn" x="361" y="0" height="40" label="Button" click="data=srv.findByKlas(Klas.text)"/>
      
        <s:List id="list" top="48" bottom="0" left="0" right="0"
        dataProvider="{data}">
        <s:itemRenderer>
        <fx:Component>
        <s:IconItemRenderer
        label="{data.Klas} - {data.Vak} - {data.Docent}"
        messageField="Positie"/>
        </fx:Component>
        </s:itemRenderer>
        </s:List>
      
      
      </s:View>
      
      
      
      and secondly the sql ".as file" :
      package dao
      {
                import flash.data.SQLConnection;
                import flash.data.SQLStatement;
                import flash.filesystem.File;
                import flash.filesystem.FileMode;
                import flash.filesystem.FileStream;
                import mx.collections.ArrayCollection;
      
                public class RoosterDAO
                {
                          public function getItem(id:int):Rooster
                          {
                                    var sql:String = "SELECT id, Klas, Vak, Docent, Lokaal, Positie, Type FROM Rooster WHERE id=?";
                                    var stmt:SQLStatement = new SQLStatement();
                                    stmt.sqlConnection = sqlConnection;
                                    stmt.text = sql;
                                    stmt.parameters[0] = id;
                                    stmt.execute();
                                    var result:Array = stmt.getResult().data;
                                    if (result && result.length == 1)
                                              return processRow(result[0]);
                                    else
                                              return null;
      
                          }
                          public function findByKlas(searchKlas:String):ArrayCollection
                          {
      
      
                                    var sql:String = "SELECT * FROM rooster WHERE Klas LIKE ?";
                                    var stmt:SQLStatement = new SQLStatement();
                                    stmt.sqlConnection = sqlConnection;
                                    stmt.text = sql;
                                    stmt.parameters[0] = "%" + searchKlas + "%";
                                    stmt.execute();
                                    var result:Array = stmt.getResult().data;
                                    if (result)
                                    {
                                              var list:ArrayCollection = new ArrayCollection();
                                              for (var i:int=0; i<result.length; i++)
                                              {
                                                        list.addItem(processRow(result[i])); 
                                              }
                                              return list;
                                    }
                                    else
                                    {
                                              return null;
                                    }
                          }
      
      
                          protected function processRow(o:Object):Rooster
                          {
                                    var rooster:Rooster = new Rooster();
                                    rooster.id = o.id;
                                    rooster.Klas = o.Klas == null ? "" : o.Klas;
                                    rooster.Vak = o.Vak == null ? "" : o.Vak;
                                    rooster.Docent = o.Docent == null ? "" : o.Docent;
                                    rooster.Lokaal = o.Lokaal == null ? "" : o.Lokaal;
                                    rooster.Positie = o.Positie == null ? "" : o.Positie;
      
                                    rooster.loaded = true;
                                    return rooster;
                          }
                          public static var _sqlConnection:SQLConnection;
      
                          public function get sqlConnection():SQLConnection
                          {
                                    if (_sqlConnection) return _sqlConnection;
                                    var file:File = File.documentsDirectory.resolvePath("rooster.db");
                                    var fileExists:Boolean = file.exists;
                                    _sqlConnection = new SQLConnection();
                                    _sqlConnection.open(file);
                                    if (!fileExists)
                                    {
                                              createDatabase();
                                              populateDatabase();
                                    }
                                    return _sqlConnection;
                          }
      
                          protected function createDatabase():void
                          {
                                    var sql:String = 
                                              "CREATE TABLE IF NOT EXISTS rooster ( "+
                                              "id INTEGER PRIMARY KEY AUTOINCREMENT, " +
                                              "Klas VARCHAR(50), " +
                                              "Vak VARCHAR(50), " +
                                              "Docent VARCHAR(50), " +
                                              "Lokaal VARCHAR(50), " + 
                                              "Positie VARCHAR(50), " +
                                              "Type VARCHAR(50), ";
                                    var stmt:SQLStatement = new SQLStatement();
                                    stmt.sqlConnection = sqlConnection;
                                    stmt.text = sql;
                                    stmt.execute(); 
                          }
      
                          protected function populateDatabase():void
                          {
                                    var file:File = File.applicationDirectory.resolvePath("assets/rooster.xml");
                                    var stream:FileStream = new FileStream();
                                    stream.open(file, FileMode.READ);
                                    var xml:XML = XML(stream.readUTFBytes(stream.bytesAvailable));
                                    stream.close();
                                    var RoosterDAO:RoosterDAO = new RoosterDAO();
                                    for each (var emp:XML in xml.Rooster)
                                    {
                                              var rooster:Rooster = new Rooster();
                                              rooster.id = emp.id;
                                              rooster.Klas = emp.Klas;
                                              rooster.Vak = emp.Vak;
                                              rooster.Docent = emp.Docent;
                                              rooster.Lokaal = emp.Lokaal;
                                              rooster.Positie = emp.Positie;
                                              rooster.Type = emp.Type;
      
      
                                    }
                          }
      
      
      
      
      
                }
      }
      
      
      
      The error is at the findByKlas function and it goes like this:
      SQLError: 'Error #3115: SQL Error.', details:'no such table: 'rooster'', operation:'execute', detailID:'2013'
                at flash.data::SQLStatement/internalExecute()
                at flash.data::SQLStatement/execute()
                at dao::RoosterDAO/findByKlas()[C:\Users\Thomas\Adobe Flash Builder 4.6\ARHC test\src\dao\RoosterDAO.as:36]
                at views::MainHomeView/__btn_click()[C:\Users\Thomas\Adobe Flash Builder 4.6\ARHC test\src\views\MainHomeView.mxml:11]
      
      
      
      
      
      
      

      If you need any more information just ask me (:

        • 1. Re: Flash builder + sqlight error #3115
          _spoboyle Community Member

          well it's a little hard to tell but this seems wrong to me

           

          protected function createDatabase():void
                              {
                                        var sql:String =
                                                  CREATE TABLE IF NOT EXISTS rooster ( +
                                                  id INTEGER PRIMARY KEY AUTOINCREMENT, +
                                                  Klas VARCHAR(50), +
                                                  Vak VARCHAR(50), +
                                                  Docent VARCHAR(50), +
                                                  Lokaal VARCHAR(50), +
                                                  Positie VARCHAR(50), +
                                                  Type VARCHAR(50), ;
                                        var stmt:SQLStatement = new SQLStatement();
                                        stmt.sqlConnection = sqlConnection;
                                        stmt.text = sql;
                                        stmt.execute();
                              }

           

           


          the blue bracket isn't closed