1 2 Previous Next 41 Replies Latest reply on Jan 8, 2013 9:57 AM by Peter Elst

    New to developing could anyone point me in the right direction for sqlite issue?

    JeanneM7289 Level 1

      Hello I am a new developer in training trying to work on my first project I have been hit by a major roadblock that i have worked on correcting for 5 days before posting here.  I am currently using flash builder 4.6 coding in flex.  I am trying to make a database that is able to be accessed accross multiple views.   I am also trying to hook up the date spinners so it search's in the Archive view between the selected dates for entries. However for the life of me I cannot seem to get a database up and running.

       

      I keep getting the following errors.

       

      Database is now open

      Error #2044: Unhandled SQLErrorEvent:. errorID=3115, operation=execute , message=Error #3115: SQL Error. , details=no such table: 'stb'   //this error is from the Journal view

      Database is now open

      Error #2044: Unhandled SQLErrorEvent:. errorID=3115, operation=execute , message=Error #3115: SQL Error. , details=no such table: 'stb' // this error is from the Archive View

       

       

       

       

       

       

      // Journal view code

       

      <s:View xmlns:fx="http://ns.adobe.com/mxml/2009"

                          xmlns:s="library://ns.adobe.com/flex/spark" title="Journal" creationComplete="createDatabase()">

       

                <fx:Script>

                          <![CDATA[

       

                                    import flash.data.SQLConnection;

                                    import flash.data.SQLStatement;

                                    import flash.errors.SQLError;

                                    import flash.events.Event;

                                    import flash.events.SQLErrorEvent;

                                    import flash.events.SQLEvent;

                                    import flash.events.TimerEvent;

                                    import flash.filesystem.File;

                                    import flash.utils.Timer;

       

                                    import mx.collections.ArrayCollection;

                                    import mx.utils.ObjectUtil;

                                    import org.osmf.events.TimeEvent;

       

       

       

       

       

                                    public var sqlc:SQLConnection = new SQLConnection();

       

                                    public var dbFile:File;

                                    public var dbConnection:SQLConnection;

       

       

                                    private function createDatabase():void

                                    {

                                              dbFile = File.applicationStorageDirectory.resolvePath("assets/appsimplicity.sqlite"); //last modified

                                              dbConnection = new SQLConnection();

                                              dbConnection.addEventListener(SQLEvent.OPEN, onDatabaseOpen);

                                              dbConnection.addEventListener(SQLEvent.CLOSE, onDatabaseClose);

       

                                              dbConnection.openAsync(dbFile);

       

                                    }

       

       

                                    private function onDatabaseOpen(evt:SQLEvent):void

                                    {

                                              trace("Database is now open");

                                              var statement:SQLStatement = new SQLStatement();

                                              statement.sqlConnection = dbConnection;

                                              statement.sqlConnection.open(appsimplicity.sqlite, SQLMode.READ);

                                              statement.text = "CREATE TABLE IF NOT EXISTS stb (id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT , entry TEXT)";          ///working on issue here

       

                                    }

       

                                    private function onDatabaseClose(evt:SQLEvent):void

                                    {

                                              trace("Database is now closed");

                                    }

       

                                    private function saveJournal():void

                                    {

       

                                              var statement:SQLStatement = new SQLStatement();

                                              statement.sqlConnection = dbConnection;

                                              statement.text = "INSERT INTO stb_ (title , entry) VALUES ('"+title_txt.text+"','"+entry.text+"')"; //is this maybe wrong?

       

                                              statement.execute();

       

                                              title_txt.text = "";

                                              entry.text = "";

       

                                    }

       

                                    //debug log

                                    //[SWF] Main.swf - 3,574,774 bytes after decompression

                                    //Database is now open

                                    //Error #2044: Unhandled SQLErrorEvent:. errorID=3115, operation=execute , message=Error #3115: SQL Error. , details=no such table: 'journallistb'

       

       

       

       

                          ]]>

                </fx:Script>

       

       

       

       

       

                <fx:Declarations>

                          <!-- Place non-visual elements (e.g., services, value objects) here -->

                </fx:Declarations>

       

       

       

                <s:Label id="title_lable_txt" x="10" y="48" width="124" height="21" color="#E2881E" text="Title:"/>

                <s:TextInput id="title_txt" x="47" y="36" width="146" enabled="true" prompt="Entry Title" needsSoftKeyboard="true" />

                <s:TextArea id="entry" x="9" y="120" height="147" enabled="true" prompt="Entry" needsSoftKeyboard="true" />

                <s:Button id="savejournal" x="11" y="326" width="296" label="Save" click="saveJournal()" />

                <s:Button id="addphotostojournal" x="11" y="275" width="296" label="Add Photos"/>

                <s:Label id="journal" x="10" y="97" color="#E2881E" text="Journal:"/>

                <s:Label id="Datefield" x="145" y="97" color="#E2881E" text="Date:"/>

                <s:TextInput id="date" x="187" y="78" width="120" height="34" enabled="true" prompt="enter date"/>

       

       

       

       

      </s:View>

       

       

      //Archive view code

       

      <?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="Archive" creationComplete="createDatabase()">

       

       

       

       

                <fx:Script>

                          <![CDATA[

       

       

                                    import mx.collections.ArrayCollection;

       

                                    public var dbFile:File

                                    public var dbConnection:SQLConnection;

                                    public var selectQuery:SQLStatement;

       

                                    private function createDatabase():void

                                    {

                                              dbFile = File.applicationDirectory.resolvePath("appsimplicity.sqlite");

                                              dbConnection = new SQLConnection();

                                              dbConnection.addEventListener(SQLEvent.OPEN, onDatabaseOpen);

                                              dbConnection.addEventListener(SQLEvent.CLOSE, onDatabaseClose);

       

       

                                              dbConnection.openAsync(dbFile);

                                    }

       

                                    private function onDatabaseOpen(evt:SQLEvent):void

                                    {

                                              trace("Database is now open");

                                              selectQuery = new SQLStatement();

                                              selectQuery.sqlConnection = dbConnection;

                                              selectQuery.text = "SELECT * FROM stb ORDER BY title ASC";

                                              selectQuery.addEventListener(SQLEvent.RESULT, onQueryResult);

       

                                              selectQuery.execute();

                                    }

       

                                    private function onQueryResult(evt:SQLEvent):void

                                    {

                                              archivefiles.dataProvider = new ArrayCollection(selectQuery.getResult().data);

                                    }

       

                                    private function onDatabaseClose(evt:SQLEvent):void

                                    {

                                              trace("Database is now Closed");

                                    }

       

                          ]]>

                </fx:Script>

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

                <fx:Declarations>

                          <!-- Place non-visual elements (e.g., services, value objects) here -->

                </fx:Declarations>

       

       

                <s:DateSpinner id="Startdate" x="66" y="54" width="40" height="60"/>

       

                <s:List id="archivefiles" x="69" y="119" width="185" height="138" enabled="true" labelField="title" ></s:List>

       

                <s:Button id="Delete" x="68" y="313" width="185" label="Delete"/>

       

                <s:VScrollBar x="248" y="120" height="138"/>

       

                <s:DateSpinner id="Enddate" x="68" y="361" width="40" height="50"/>

       

                <s:Label id="adspace" x="0" y="0" width="321" height="36" color="#751E1E" text="AdSpace"/>

       

       

       

       

      </s:View>

       

       

      I made the data base using sqlite manager "Firefox plugin" then copied it to a new package I called assets. inside the project SRC folder.  I am at a lose, and any help would be greatly appreciated! 

       

      Message was edited by: JeanneM7289  updated with tags

        • 1. Re: New to developing could anyone point me in the right direction for sqlite issue?
          JeanneM7289 Level 1

          sooo  no help from the adobe community regarding an adobe product?

          • 2. Re: New to developing could anyone point me in the right direction for sqlite issue?
            BBlommers Level 2

            Whoah, hold your horses... You cannot expect volunteers to reply within one hour. Some patience is appreciated.

             

            Try replacing the following methods. I've added some logging, and added a statement.execute()-statement.

             

             

            private function createDatabase():void

                                          {

                                                    dbFile = File.applicationStorageDirectory.resolvePath("assets/appsimplicity.sq lite"); //last modified

                                                    dbConnection = new SQLConnection();

                                                    dbConnection.addEventListener(SQLEvent.OPEN, onDatabaseOpen);

                                                    dbConnection.addEventListener(SQLEvent.ERROR, onDatabaseError);        //***** added by bblommers

                                                    dbConnection.addEventListener(SQLEvent.CLOSE, onDatabaseClose);

             

                                                    dbConnection.openAsync(dbFile);

             

                                          }

             

                                         private function onDatabaseError(evt:SQLEvent):void     ////************ added by bblommers

            {

                 trace('Error with the database: '+evt);

            }

             

             

                                          private function onDatabaseOpen(evt:SQLEvent):void

                                          {

                                                    trace("Database is now open");

                                                    var statement:SQLStatement = new SQLStatement();

                                                    statement.sqlConnection = dbConnection;

                                                    statement.sqlConnection.open(appsimplicity.sqlite, SQLMode.READ);

                                                    statement.text = "CREATE TABLE IF NOT EXISTS stb (id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT , entry TEXT)";          ///working on issue here

                                                    statement.execute();                    //************* added by bblommers

                                                     trace("Table is now created");     //************ added by bblommers

                                          }

            • 3. Re: New to developing could anyone point me in the right direction for sqlite issue?
              JeanneM7289 Level 1

              Thank you I will try this out asap "When FB gets fixed from last nights update Darn Eclipse plugin "  on a second note please dont think I am trying to be pushy I am just stressed 6 days now on this issue and the trainings I purchased dont cover SQLite or databases at all   

              Peter Elst, Joseph Labrecque both really really failed there readers on the training for this!"

              • 4. Re: New to developing could anyone point me in the right direction for sqlite issue?
                JeanneM7289 Level 1

                I am now getting the error.

                 

                Error: Error #3101: Database connection is already open.

                          at Error$/throwError()

                          at flash.data::SQLConnection/open()

                          at views::HomeView/onDatabaseOpen()[C:\Users/blah\Adobe Flash Builder 4.6\appSimplicity Journal\src\views\HomeView.mxml:55]

                 

                 

                <s:View xmlns:fx="http://ns.adobe.com/mxml/2009"

                                    xmlns:s="library://ns.adobe.com/flex/spark" title="Journal" creationComplete="createDatabase()">

                 

                          <fx:Script>

                                    <![CDATA[

                 

                                              import flash.data.SQLConnection;

                                              import flash.data.SQLStatement;

                                              import flash.errors.SQLError;

                                              import flash.events.Event;

                                              import flash.events.SQLErrorEvent;

                                              import flash.events.SQLEvent;

                                              import flash.events.TimerEvent;

                                              import flash.filesystem.File;

                                              import flash.utils.Timer;

                 

                                              import mx.collections.ArrayCollection;

                                              import mx.utils.ObjectUtil;

                 

                                              import org.osmf.events.TimeEvent;

                 

                 

                 

                 

                 

                                              public var sqlc:SQLConnection = new SQLConnection();

                 

                                              public var dbFile:File;

                                              public var dbConnection:SQLConnection;

                 

                 

                                              private function createDatabase():void

                                              {

                                                        dbFile = File.applicationStorageDirectory.resolvePath("appsimplicity.sqlite"); //last modified

                                                        dbConnection = new SQLConnection();

                                                        dbConnection.addEventListener(SQLEvent.OPEN, onDatabaseOpen);             ////************ added by bblommers

                                                        dbConnection.addEventListener(SQLErrorEvent.ERROR, onDatabaseError);  

                                                        dbConnection.addEventListener(SQLEvent.CLOSE, onDatabaseClose);

                 

                                                        dbConnection.openAsync(dbFile);

                 

                                              }

                 

                                              private function onDatabaseError(evt:SQLEvent):void    

                                              {

                                                        trace('Error with the database: '+evt);

                                              }

                 

                 

                                              private function onDatabaseOpen(evt:SQLEvent):void

                                              {

                                                        trace("Database is now open");

                                                        var statement:SQLStatement = new SQLStatement();

                                                        statement.sqlConnection = dbConnection;

                                                        statement.sqlConnection.open("appsimplicity.sqlite", SQLMode.READ);

                                                        statement.text = "CREATE TABLE IF NOT EXISTS stb (id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT , entry TEXT)";          ///working on issue here

                                                        statement.execute();                    //************* added by bblommers

                                                        trace("Table is now created");     //************ added by bblommers

                                              }

                 

                                              private function onDatabaseClose(evt:SQLEvent):void

                                              {

                                                        trace("Database is now closed");

                                              }

                 

                                              private function saveJournal():void

                                              {

                 

                                                        var statement:SQLStatement = new SQLStatement();

                                                        statement.sqlConnection = dbConnection;

                                                        statement.text = "INSERT INTO stb (title , entry) VALUES ('"+title_txt.text+"','"+entry.text+"')"; //is this maybe wrong?

                 

                                                        statement.execute();

                 

                                                        title_txt.text = "";

                                                        entry.text = "";

                 

                                              }

                 

                                              //debug log

                                              //[SWF] Main.swf - 3,574,774 bytes after decompression

                                              //Database is now open

                                              //Error #2044: Unhandled SQLErrorEvent:. errorID=3115, operation=execute , message=Error #3115: SQL Error. , details=no such table: 'journallistb'

                 

                 

                 

                 

                                    ]]>

                          </fx:Script>

                 

                 

                 

                 

                 

                          <fx:Declarations>

                                    <!-- Place non-visual elements (e.g., services, value objects) here -->

                          </fx:Declarations>

                 

                 

                 

                          <s:Label id="title_lable_txt" x="10" y="48" width="124" height="21" color="#E2881E" text="Title:"/>

                          <s:TextInput id="title_txt" x="47" y="36" width="146" enabled="true" prompt="Entry Title" needsSoftKeyboard="true" />

                          <s:TextArea id="entry" x="9" y="120" height="147" enabled="true" prompt="Entry" needsSoftKeyboard="true" />

                          <s:Button id="savejournal" x="11" y="326" width="296" label="Save" click="saveJournal()" />

                          <s:Button id="addphotostojournal" x="11" y="275" width="296" label="Add Photos"/>

                          <s:Label id="journal" x="10" y="97" color="#E2881E" text="Journal:"/>

                          <s:Label id="Datefield" x="145" y="97" color="#E2881E" text="Date:"/>

                          <s:TextInput id="date" x="187" y="78" width="120" height="34" enabled="true" prompt="enter date"/>

                 

                 

                 

                on the archive view I am still getting the error

                 

                Error #2044: Unhandled SQLErrorEvent:. errorID=3115, operation=execute , message=Error #3115: SQL Error. , details=no such table: 'stb'

                 

                 

                However the journal view Trace show's Table created and Database opened  I am at my wits end with this

                • 5. Re: New to developing could anyone point me in the right direction for sqlite issue?
                  John Hall Level 4

                  Were I you, I'm not sure I'd take off on Peter and Joseph, both big contributors in the Flex community. If the tutorials you're looking at don't work for you, remember it's hard to predict exactly where everyone, as far as experience, is coming into an instructional piece. Re: your error, so you're using AIR with SQLite? The error message you're getting is pretty descriptive, it looks like you're already opened a connection and you're trying to open it again. As far as SQLite goes, I'd Google Paul Robertson. He's done a whole lot on SQLite and Flex and even has a couple of videos out there from old presentations that remain helpful. His things are where I learned most of my SQLite/AIR knowledge.

                  • 6. Re: New to developing could anyone point me in the right direction for sqlite issue?
                    JeanneM7289 Level 1

                    @john Hall

                     

                    Thank you very much for the direction to Paul Robertson.  

                     

                    On a side note I am sure Peter and Joseph are wonderful people, However my opinion of the training video that I paid for still stand. I think it was Peter Elst who only spent 15 minutes on this topic in video "Video2brain.com mobile development with adobe flash proffessional cs5.5 and Flash Builder 4.5: learn by video"  so all im saying is the description:

                     

                    In this in-depth course you’ll learn everything you need to know to start developing for mobile and devices on Android and iOS using Flash Platform technology. Top Flash Platform experts Peter Elst and Joseph Labrecque will walk you through the entire workflow from application setup to development and deployment, covering best practices for mobile development and how to debug the applications you create on the desktop or on a device. Along the way you’ll learn how to work with gestures, touch events, hardware APIs, data, multimedia features, and much more. After completing this course you’ll be well on your way to making your mobile projects a reality. This Learn by Video workshop is published in partnership with Peachpit Press.

                     

                     

                    was not true.  sure it is a marketing thing.  I am all for honest mistakes lord knows i make them

                    • 7. Re: New to developing could anyone point me in the right direction for sqlite issue?
                      BBlommers Level 2

                      It looks like you're opening the database twice:

                       

                      private function onDatabaseOpen(evt:SQLEvent):void

                      {

                           [..]

                           statement.sqlConnection.open("appsimplicity.sqlit e", SQLMode.READ);

                           [...]

                      }

                       

                      I don't think this line is necessary, since this connection already is open.

                       

                      Edit: This would result in the Error: Error #3101: Database connection is already open.

                      The second error, that the database table 'std' does not exist, is a result of this; the method fails before it can get to creating that table.

                       

                      Message was edited by: BBlommers, explanation why and how

                      • 8. Re: New to developing could anyone point me in the right direction for sqlite issue?
                        JeanneM7289 Level 1

                        @BBloomers

                        I am not getting errors anymore on the journal view the archive view is still throwing:

                         

                        Error #2044: Unhandled SQLErrorEvent:. errorID=3115, operation=execute , message=Error #3115: SQL Error. , details=no such table: 'stb'

                         

                         

                        the code is :

                         

                        <?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="Archive" creationComplete="createDatabase()">

                         

                         

                         

                         

                                  <fx:Script>

                         

                         

                                            <![CDATA[

                         

                         

                                                      import mx.collections.ArrayCollection;

                         

                                                      public var dbFile:File

                                                      public var dbConnection:SQLConnection;

                                                      public var selectQuery:SQLStatement;

                         

                                                      private function createDatabase():void

                                                      {

                                                                dbFile = File.applicationDirectory.resolvePath("appsimplicity.sqlite");

                                                                dbConnection = new SQLConnection();

                                                                dbConnection.addEventListener(SQLEvent.OPEN, onDatabaseOpen);

                                                                dbConnection.addEventListener(SQLEvent.CLOSE, onDatabaseClose);

                         

                         

                                                                dbConnection.openAsync(dbFile);

                                                      }

                         

                                                      private function onDatabaseOpen(evt:SQLEvent):void

                                                      {

                                                                trace("Database is now open");

                                                                selectQuery = new SQLStatement();

                                                                selectQuery.sqlConnection = dbConnection;

                                                                selectQuery.text = "SELECT * FROM stb ORDER BY title ASC";

                                                                selectQuery.addEventListener(SQLEvent.RESULT, onQueryResult);

                         

                                                                selectQuery.execute();

                                                      }

                         

                                                      private function onQueryResult(evt:SQLEvent):void

                                                      {

                                                                archivefiles.dataProvider = new ArrayCollection(selectQuery.getResult().data);

                                                      }

                         

                                                      private function onDatabaseClose(evt:SQLEvent):void

                                                      {

                                                                trace("Database is now Closed");

                                                      }

                         

                                            ]]>

                                  </fx:Script>

                         

                         

                         

                         

                         

                         

                         

                         

                         

                         

                         

                         

                         

                         

                         

                         

                                  <fx:Declarations>

                                            <!-- Place non-visual elements (e.g., services, value objects) here -->

                                  </fx:Declarations>

                         

                         

                                  <s:DateSpinner id="Startdate" x="66" y="54" width="40" height="60"/>

                         

                                  <s:List id="archivefiles" x="69" y="119" width="185" height="138" enabled="true" labelField="title" ></s:List>

                         

                                  <s:Button id="Delete" x="68" y="313" width="185" label="Delete"/>

                         

                                  <s:VScrollBar x="248" y="120" height="138"/>

                         

                                  <s:DateSpinner id="Enddate" x="68" y="361" width="40" height="50"/>

                         

                                  <s:Label id="adspace" x="0" y="0" width="321" height="36" color="#751E1E" text="AdSpace"/>

                         

                         

                         

                         

                        </s:View>

                         

                         

                        The solutions you have provided seem to have worked for the Journal view because you rock im sure

                        • 9. Re: New to developing could anyone point me in the right direction for sqlite issue?
                          John Hall Level 4

                          And the stb table exists outside of being created in your program? i.e., the obvious, do you see the stb table if you look at it through a SQL admin tool of some sort?

                          • 10. Re: New to developing could anyone point me in the right direction for sqlite issue?
                            JeanneM7289 Level 1

                            i copied the appsimplicity.sqlite file from the bin-debug folder to my desktop and oponed with sqlite manager   the table does not show   gonna look into fixing that right now  

                            • 11. Re: New to developing could anyone point me in the right direction for sqlite issue?
                              JeanneM7289 Level 1

                              // this is the code im using to create the table

                               

                              private function onDatabaseOpen(evt:SQLEvent):void

                                                            {

                                                                      trace("Database is now open");

                                                                      var statement:SQLStatement = new SQLStatement();

                                                                      statement.sqlConnection = dbConnection;

                               

                                                                      statement.text = "CREATE TABLE IF NOT EXISTS stb (id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT , entry TEXT, date INTEGER)";          ///working on issue here

                                                                      statement.execute();                    //************* added by bblommers

                                                                      trace("Table is now created");     //************ added by bblommers

                               

                               

                               

                              //This is the code to save data to the table

                               

                              private function saveJournal():void

                                                            {

                               

                                                                      var statement:SQLStatement = new SQLStatement();

                                                                      statement.sqlConnection = dbConnection;

                                                                      statement.text = "INSERT INTO stb (title , entry, date) VALUES ('"+title_txt.text+"','"+entry.text+"','"+date.text+"')"; //is this maybe wrong?

                               

                                                                      trace(getTimer());

                               

                                                                      statement.execute();

                               

                                                                      title_txt.text = "";

                                                                      entry.text = "";

                               

                                                            }

                              • 12. Re: New to developing could anyone point me in the right direction for sqlite issue?
                                John Hall Level 4

                                I'm more suspicious of the createTable statement. Though I don't have time to diagnose the way you're creating it (which is fine) I use a queue and I certainly have to construct the whole string, not use the words as you would in a direct SQL statement. For instance, this works for me:

                                 

                                q.addItem( "CREATE TABLE Addresses (" + "    GUID TEXT PRIMARY KEY , " + "    address1 TEXT, " + "    address2 TEXT, " + "    city TEXT, " + "    state TEXT, " + "    zip TEXT, " + "  addressType TEXT, " + "  country TEXT, " + "    latitude numeric, " + "    longitude numeric" + ")", [], true );

                                • 13. Re: New to developing could anyone point me in the right direction for sqlite issue?
                                  JeanneM7289 Level 1

                                  @ John Hall

                                   

                                  I am working right now to modify my createtable statement.  Ill post it soon as im finished to see what you all think.    Thanks so much for the help so far, I have been in this database nightmare for over a week now! I think im finaly seeing a light at the end of the Table err i mean Tunnel >.> <.<

                                  • 14. Re: New to developing could anyone point me in the right direction for sqlite issue?
                                    JeanneM7289 Level 1

                                    New table and new error *Sigh*

                                     

                                    Error #3108: Operation is not permitted when the SQLStatement.text property is not set.

                                     

                                     

                                    I have the                                      public var createStatement :SQLStatement;

                                     

                                    And its called in the onDatabaseOpen

                                     

                                    createStatement = new SQLStatement();

                                     

                                    private function onDatabaseOpen(evt:SQLEvent):void

                                                                  {

                                                                            trace("Database is now open");

                                                                            var statement:SQLStatement = new SQLStatement();

                                                                            statement.sqlConnection = dbConnection;

                                                                            createStatement = new SQLStatement();

                                     

                                                                            createStatement.text = "CREATE TABLE IF NOT EXISTS stb (      " +

                                                                                      "id          INTEGER PRIMARY KEY AUTOINCREMENT, " +

                                                                                      "title TEXT,                                    " +

                                                                                      "entry TEXT,                                    " +

                                                                                      "date INTEGER                                   " +

                                                                                      ")";                                           //working on issue here

                                                                            statement.execute();                               //************ added by bblommers

                                                                            trace("Table is now created");                     //************ added by bblommers

                                                                  }

                                     

                                     

                                    Any Ideas?

                                    • 15. Re: New to developing could anyone point me in the right direction for sqlite issue?
                                      John Hall Level 4

                                      Should that be

                                       

                                      var createStatement:SQLStatement = new SQLStatement();

                                      createStatement.sqlConnection .....

                                       

                                      .....

                                      createStatement.execute()

                                       

                                      ?

                                      • 16. Re: New to developing could anyone point me in the right direction for sqlite issue?
                                        JeanneM7289 Level 1

                                        Made those changes got this error again

                                         

                                        [SWF] Main.swf - 3,575,415 bytes after decompression

                                        Database is now open

                                        Error: Error #3109: Operation is not permitted when the SQLStatement.sqlConnection property is not set.

                                                  at Error$/throwError()

                                                  at flash.data::SQLStatement/checkAllowed()

                                                  at flash.data::SQLStatement/checkReady()

                                                  at flash.data::SQLStatement/execute()

                                                  at views::JournalView/onDatabaseOpen()[C:\Users\ezExecustaff\Adobe Flash Builder 4.6\appSimplicity Journal\src\views\JournalView.mxml:64]

                                         

                                         

                                        //code

                                         

                                        private function onDatabaseOpen(evt:SQLEvent):void

                                                                      {

                                                                                trace("Database is now open");

                                                                                var createStatement:SQLStatement = new SQLStatement();

                                                                                createStatement.sqlConnection = dbConnection;

                                                                                createStatement = new SQLStatement();

                                         

                                                                                createStatement.text = "CREATE TABLE IF NOT EXISTS stb (      " +

                                                                                          "id          INTEGER PRIMARY KEY AUTOINCREMENT, " +

                                                                                          "title TEXT,                                    " +

                                                                                          "entry TEXT,                                    " +

                                                                                          "date INTEGER                                   " +

                                                                                          ")";                                           //working on issue here

                                                                                createStatement.execute();                               //************ added by bblommers

                                                                                trace("Table is now created");                     //************ added by bblommers

                                                                      }

                                        • 17. Re: New to developing could anyone point me in the right direction for sqlite issue?
                                          John Hall Level 4

                                          Now it sounds like the connection isn't open again. I'm about to take off. If you haven't already run into this one, it seems like a good intro by Paul. Just double check spellings and syntax:

                                           

                                          http://www.adobe.com/devnet/air/flash/quickstart/articles/simple_sql_database.html

                                          • 19. Re: New to developing could anyone point me in the right direction for sqlite issue?
                                            JeanneM7289 Level 1

                                            nope    I am starting over from scratch trying to get a database to even create itself.  

                                            • 20. Re: New to developing could anyone point me in the right direction for sqlite issue?
                                              John Hall Level 4

                                              If you're willing to post a link to a bare-bones example of where you're at, I'm sure that more than one person would try to help.

                                              • 21. Re: New to developing could anyone point me in the right direction for sqlite issue?
                                                JeanneM7289 Level 1

                                                So I think i got a working solution I made a actionscript function to create a database and establish a connection so it would be cleaner I am trying to make sure the .asfile runs on creation. 

                                                 

                                                creationComplete="sqlConnect(dbName:String, dbtbstmt:String, dbinsert:String)

                                                 

                                                However I seem to be getting the error.

                                                DescriptionResourcePathLocationType
                                                1084: Syntax error: expecting rightparen before colon.JournalView.mxml/appSimplicity Journal/src/viewsline 2Flex Problem

                                                I added a ) before each : individually and tested got same error message, Tried putting a ) infront of all the :  that resulted in many many errors >.>    so any ideas?

                                                • 22. Re: New to developing could anyone point me in the right direction for sqlite issue?
                                                  JeanneM7289 Level 1

                                                  what I have posted is all I have,  I am very new to all of this and struggling to learn it, So i dont know how much more bare bones I can make it other then giving everything I have written in the post.  

                                                  • 23. Re: New to developing could anyone point me in the right direction for sqlite issue?
                                                    BBlommers Level 2

                                                    In post #16, I think you we're pretty close. However, there is no need to instantiate the createStatement-object twice.

                                                    The moment you instantiate the object after the sqlConnection is set, this connection is disregarded.

                                                     

                                                    The creation complete statement only works with statements, not with function initializers.

                                                    To execute a different AS-file, use something like this:

                                                     

                                                    creationComplete("new MyDbObject().sqlConnect('dbName','create table[…]','[…]')")

                                                    • 24. Re: New to developing could anyone point me in the right direction for sqlite issue?
                                                      JeanneM7289 Level 1

                                                      @BBloomers   I will try that out !    I think your right we where close at #16 only problem is that when I updated flash builder   flash builder broke with a eclipse plugin problem so I had to uninstall then reinstall and lost the work

                                                      • 25. Re: New to developing could anyone point me in the right direction for sqlite issue?
                                                        JeanneM7289 Level 1

                                                        making a database is truly a nightmare for me ....

                                                        • 26. Re: New to developing could anyone point me in the right direction for sqlite issue?
                                                          John Hall Level 4

                                                          Well, can't say this is all best practice below (and I'm too lazy to protect my reputation by making it so ;-) but something along these lines should at least create the database:

                                                           

                                                          <?xml version = "1.0" encoding = "utf-8"?>

                                                          <s:WindowedApplication xmlns:fx = "http://ns.adobe.com/mxml/2009"

                                                                                                               xmlns:s = "library://ns.adobe.com/flex/spark"

                                                                                                               xmlns:mx = "library://ns.adobe.com/flex/mx"

                                                                                                               creationComplete="init()">

                                                                    <fx:Script>

                                                                              <![CDATA[

                                                                                        protected var dbFile : File

                                                                                        protected var dbConnection : SQLConnection;

                                                                                        protected var createStatement:SQLStatement;

                                                           

                                                                                        private function init():void{

                                                                                                  dbFile = File.documentsDirectory.resolvePath( "appsimplicity.db" );

                                                                                                  dbConnection = new SQLConnection();

                                                                                                  dbConnection.addEventListener( SQLEvent.OPEN, onDatabaseOpen );

                                                                                                  dbConnection.openAsync( dbFile );

                                                                                        }

                                                           

                                                                                        private function onDatabaseOpen( evt : SQLEvent ) : void {

                                                                                                  createStatement = new SQLStatement();

                                                                                                  createStatement.sqlConnection = dbConnection;

                                                                                                  createStatement.text = "CREATE TABLE IF NOT EXISTS stb (      " +

                                                                                                            "id          INTEGER PRIMARY KEY AUTOINCREMENT, " +

                                                                                                            "title TEXT,                                    " +

                                                                                                            "entry TEXT,                                    " +

                                                                                                            "date INTEGER                                   " +

                                                                                                            ")";                                            //working on issue here

                                                                                                  createStatement.execute();                                //************ added by bblommers

                                                                                        }

                                                                              ]]>

                                                                    </fx:Script>

                                                           

                                                                    <s:List id = "archivefiles"

                                                                                        x = "69"

                                                                                        y = "119"

                                                                                        width = "185"

                                                                                        height = "138"

                                                                                        enabled = "true"

                                                                                        labelField = "title">

                                                                    </s:List>

                                                          </s:WindowedApplication>

                                                          • 27. Re: New to developing could anyone point me in the right direction for sqlite issue?
                                                            John Hall Level 4

                                                            Whoops, I guess out of habit I put it in the documents folder, but you get the idea.

                                                            • 29. Re: New to developing could anyone point me in the right direction for sqlite issue?
                                                              JeanneM7289 Level 1

                                                              Thanks Guys! I think it is working now!!!

                                                               

                                                              [SWF] Main.swf - 3,420,357 bytes after decompression

                                                              Db Created

                                                              Table Created

                                                              [Unload SWF] Main.swf

                                                               

                                                               

                                                              However shouldnt it make a file in the file tree named appsimplicity.db?   I am not seeing it create however the trace statements are running.   I changed the resolve path to

                                                               

                                                              dbFile = File.applicationStorageDirectory.resolvePath( "appsimplicity.db" );

                                                               

                                                               

                                                              again Ya'll Rock!

                                                              • 30. Re: New to developing could anyone point me in the right direction for sqlite issue?
                                                                John Hall Level 4

                                                                Yes, it should create a physical file that you can open with a SQLite editor. You don't see anything in your appData/Local/ folder that looks like it? Are you showing hidden files? I'm clueless on Mac location though, using Windows.

                                                                • 31. Re: New to developing could anyone point me in the right direction for sqlite issue?
                                                                  JeanneM7289 Level 1

                                                                  I am on windows 7 aswell.   No file populates at all in the project tree to be a database.   odd...   this is a mobile application aswell.

                                                                  • 32. Re: New to developing could anyone point me in the right direction for sqlite issue?
                                                                    Peter Elst

                                                                    Hi JeanneM7289 - I only just found this thread, apologies - are you still having problems with SQLite? Feel free to reach out to me directly, peter.elst at gmail and I'd be happy to help you along.

                                                                     

                                                                    I don't disagree that a few of the topics in the video training, including SQLite are a bit rushed - that said in our defense we wanted to cover a broad spectrum of topics for people starting with mobile development using Flex and AIR, something that turned out to be difficult within the time constraints given. Appreciate the feedback though.

                                                                    • 33. Re: New to developing could anyone point me in the right direction for sqlite issue?
                                                                      JeanneM7289 Level 1

                                                                      Still having lots of problems.   The database never create's the trace statements all correctly trace, however it does not create a new db file or database in the tree anywhere.  I am trying to do a mobile app, so I dont know if the emulator would create it or not.   I tried to reach adobe to find out if Flex was having a pathing issue 8 hours later I was informed they dont know anything about FB unless you buy a support contract $250.00 + /sadface.  

                                                                      • 34. Re: New to developing could anyone point me in the right direction for sqlite issue?
                                                                        Peter Elst Level 1

                                                                        If you like feel free to email me your latest source code and I'll see if I can debug it for you. It sounds like a relatively easy problem to debug, shouldn't even have to contemplate a support contract.

                                                                         

                                                                        I've worked on a pretty cool wrapper class that makes it easy to set up SQL databases with an MXML tag, if you'd like to try that:

                                                                         

                                                                        http://code.google.com/p/sqlite-wrapper/

                                                                         

                                                                        I noticed earlier you're going for applicationStorageDirectory which doensn't actually exist until the application is installed so that doesn't work in the emulator. You can try just changing it to something like File.desktopDirectory and see if it shows up.

                                                                         

                                                                        Cheers,

                                                                        Peter

                                                                        • 35. Re: New to developing could anyone point me in the right direction for sqlite issue?
                                                                          John Hall Level 4

                                                                          I certainly hope it helps Jeanne but I know I'll take advantage of it. Thanks for sharing.

                                                                          • 36. Re: New to developing could anyone point me in the right direction for sqlite issue?
                                                                            JeanneM7289 Level 1

                                                                            Definatly will look into this when the family heads out they are down for the holidays.  Thank you everyone for keeping up with this post it is greatly appreciated.   I will try changing the file save destination first thing on the 6th and get back with everyone with the results.  

                                                                             

                                                                             

                                                                             

                                                                            JM

                                                                            • 37. Re: New to developing could anyone point me in the right direction for sqlite issue?
                                                                              JeanneM7289 Level 1

                                                                              <?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="Journal" backgroundColor="0x000000"

                                                                                                  >

                                                                               

                                                                                        <fx:Script>

                                                                                                  <![CDATA[

                                                                                                            import mx.utils.OnDemandEventDispatcher;

                                                                                                            import mx.collections.ArrayCollection;

                                                                               

                                                                               

                                                                                                            public var dbFile:File;

                                                                                                            public var dbConnection:SQLConnection; // open stmt

                                                                               

                                                                                                            private function createDatabase():void

                                                                                                            {

                                                                                                                      dbFile = File.desktopDirectory.resolvePath("database.db"); //path of the Db File

                                                                                                                      dbConnection = new SQLConnection();

                                                                                                                      dbConnection.addEventListener(SQLEvent.OPEN, onDatabaseOpen);

                                                                                                                      dbConnection.addEventListener(SQLEvent.CLOSE, onDatabaseClose);

                                                                               

                                                                                                                      dbConnection.open(dbFile);

                                                                               

                                                                                                            }

                                                                               

                                                                               

                                                                                                            private function onDatabaseOpen(evt:SQLEvent):void

                                                                                                            {

                                                                                                                      trace("Database is now open"); // confirm connection to db

                                                                                                                      var statement:SQLStatement = new SQLStatement();

                                                                                                                      statement.sqlConnection = dbConnection;

                                                                                                                      statement.text =

                                                                                                                                "CREATE TABLE IF NOT EXISTS alist " +

                                                                                                                                "(id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT , journal TEXT)";

                                                                               

                                                                                                                      statement.execute();

                                                                               

                                                                                                            }

                                                                               

                                                                                                            private function onDatabaseClose(evt:SQLEvent):void

                                                                                                            {

                                                                                                                      trace("Database is now closed");

                                                                                                            }

                                                                               

                                                                                                            private function saveJournal():void

                                                                                                            {

                                                                               

                                                                                                                      var statement:SQLStatement = new SQLStatement();

                                                                                                                      statement.sqlConnection = dbConnection;

                                                                                                                      statement.text = "INSERT INTO alist (title , journal) VALUES ('"+title_txt.text+"','"+journal_txt.text+"')";

                                                                               

                                                                                                                      statement.execute();

                                                                               

                                                                                                                      title_txt.text = "";

                                                                                                                      journal_txt.text = "";

                                                                               

                                                                                                            }

                                                                               

                                                                               

                                                                                                  ]]>

                                                                                        </fx:Script>

                                                                               

                                                                               

                                                                               

                                                                               

                                                                               

                                                                                        <fx:Declarations>

                                                                                                  <!-- Place non-visual elements (e.g., services, value objects) here -->

                                                                                        </fx:Declarations>

                                                                               

                                                                               

                                                                               

                                                                                        <s:Label id="title_lable_txt" x="10" y="48" width="124" height="21" color="#E2881E" text="Title:"/>

                                                                                        <s:TextInput id="title_txt" x="47" y="36" width="146" enabled="true" prompt="Entry Title" needsSoftKeyboard="true" />

                                                                                        <s:TextArea id="journal_txt" x="9" y="120" height="147" enabled="true" prompt="Entry" needsSoftKeyboard="true" />

                                                                                        <s:Button id="savejournal" x="11" y="326" width="296" label="Save" click="saveJournal()" />

                                                                                        <s:Button id="addphotostojournal" x="11" y="275" width="296" label="Add Photos"/>

                                                                                        <s:Label id="journal" x="10" y="97" color="#E2881E" text="Journal:"/>

                                                                               

                                                                               

                                                                               

                                                                               

                                                                               

                                                                              </s:View>

                                                                              • 38. Re: New to developing could anyone point me in the right direction for sqlite issue?
                                                                                JeanneM7289 Level 1

                                                                                thats my code as of now,  I tried a much more elaborate version to create a db using Action script. I will attach that one aswell

                                                                                 

                                                                                sqlconnect.as  "View file"

                                                                                 

                                                                                 

                                                                                 

                                                                                import flash.data.SQLConnection;

                                                                                import flash.data.SQLResult;

                                                                                import flash.data.SQLStatement;

                                                                                import flash.errors.SQLError;

                                                                                import flash.events.Event;

                                                                                import flash.events.SQLErrorEvent;

                                                                                import flash.events.SQLEvent;

                                                                                import flash.filesystem.File;

                                                                                 

                                                                                 

                                                                                 

                                                                                 

                                                                                public function sqlConnect(dbName:String, dbtbstmt:String, dbinsert:String): void

                                                                                {

                                                                                          var sqlconn:SQLConnection = new SQLConnection;

                                                                                          var tbcreate:SQLStatement = new SQLStatement;

                                                                                          var insertst:SQLStatement = new SQLStatement;

                                                                                          var folder:File = File.applicationStorageDirectory

                                                                                          var dbPath:File = folder.resolvePath(dbName);

                                                                                 

                                                                                 

                                                                                          sqlconn.addEventListener(SQLEvent.OPEN, dbCreated);

                                                                                          sqlconn.addEventListener(SQLErrorEvent.ERROR, dbError);

                                                                                          tbcreate.addEventListener(SQLEvent.RESULT, tbCreated);

                                                                                          tbcreate.addEventListener(SQLErrorEvent.ERROR, tbError);

                                                                                          insertst.addEventListener(SQLEvent.RESULT, recCreated);

                                                                                          insertst.addEventListener(SQLErrorEvent.ERROR, recError);

                                                                                 

                                                                                          sqlconn.openAsync(dbPath);

                                                                                 

                                                                                          tbcreate.sqlConnection = sqlconn;

                                                                                          tbcreate.text = dbtbstmt;

                                                                                 

                                                                                          tbcreate.execute();

                                                                                 

                                                                                          insertst.sqlConnection = sqlconn;

                                                                                          insertst.text = dbinsert;

                                                                                 

                                                                                          insertst.execute();

                                                                                 

                                                                                 

                                                                                }

                                                                                 

                                                                                 

                                                                                 

                                                                                 

                                                                                private function dbCreated(event:SQLEvent):void

                                                                                {

                                                                                          trace("Database Created");

                                                                                }

                                                                                 

                                                                                 

                                                                                private function dbError(event:SQLErrorEvent):void

                                                                                {

                                                                                          trace("Error message:" + event.error.message);

                                                                                          trace("Details:" + event.error.details);

                                                                                }

                                                                                 

                                                                                 

                                                                                private function tbCreated(event:SQLEvent):void

                                                                                {

                                                                                          trace("Table Created");

                                                                                }

                                                                                 

                                                                                 

                                                                                private function tbError(event:SQLErrorEvent):void

                                                                                {

                                                                                          trace("Error message:" + event.error.message);

                                                                                          trace("Details:" + event.error.details);

                                                                                }

                                                                                 

                                                                                 

                                                                                private function recCreated(event:SQLEvent):void

                                                                                {

                                                                                          trace("Record Created");

                                                                                }

                                                                                 

                                                                                 

                                                                                private function recError(event:SQLErrorEvent):void

                                                                                {

                                                                                          trace("Error message:" + event.error.message);

                                                                                          trace("Details:" + event.error.details);

                                                                                }

                                                                                 

                                                                                ------------------------------------------------------------------------------------------ ---------

                                                                                 

                                                                                Journalview file

                                                                                 

                                                                                <s:View xmlns:fx="http://ns.adobe.com/mxml/2009"

                                                                                                    xmlns:s="library://ns.adobe.com/flex/spark" title="Journal" backgroundColor="0x000000" >

                                                                                 

                                                                                 

                                                                                 

                                                                                <fx:Script source="sqlconnect.as"/>

                                                                                 

                                                                                          <fx:Script>

                                                                                                    <![CDATA[

                                                                                                              import flash.events.FileListEvent;

                                                                                 

                                                                                                              import mx.events.FlexEvent;

                                                                                 

                                                                                                              private function save():void

                                                                                                              {

                                                                                                                        var dbname:String = "apsj.db";

                                                                                                                        var sqltbstmt:String =

                                                                                                                                  "CREATE TABLE IF NOT EXISTS stb (      " +

                                                                                                                                  "id          INTEGER PRIMARY KEY AUTOINCREMENT, " +

                                                                                                                                  "title TEXT,                                    " +

                                                                                                                                  "entry TEXT,                                    " +

                                                                                                                                  "date INTEGER                                   " +

                                                                                                                                  ")"; 

                                                                                 

                                                                                                                        var sqlinsert:String =

                                                                                                                                  "INSERT INTO stb (title , entry, date) VALUES ('"+title_txt.text+"','"+entry.text+"','"+date.text+"')";

                                                                                 

                                                                                                                        sqlConnect(dbname, sqltbstmt, sqlinsert);

                                                                                 

                                                                                 

                                                                                 

                                                                                                              }

                                                                                 

                                                                                                              public function CompleteHandler(event:FlexEvent):void

                                                                                                    {

                                                                                 

                                                                                                                        sqlConnect("dbName:String", "dbtbstmt:String", "dbinsert:String");

                                                                                 

                                                                                                    }

                                                                                 

                                                                                 

                                                                                 

                                                                                                    ]]>

                                                                                          </fx:Script>

                                                                                 

                                                                                 

                                                                                 

                                                                                 

                                                                                 

                                                                                          <fx:Declarations>

                                                                                 

                                                                                 

                                                                                          </fx:Declarations>

                                                                                 

                                                                                 

                                                                                 

                                                                                          <s:Label id="title_lable_txt" x="10" y="48" width="124" height="21" color="#E2881E" text="Title:"/>

                                                                                          <s:TextInput id="title_txt" x="47" y="36" width="146" enabled="true" prompt="Entry Title" needsSoftKeyboard="true" />

                                                                                          <s:TextArea id="entry" x="9" y="120" height="147" enabled="true" prompt="Entry" needsSoftKeyboard="true" />

                                                                                          <s:Button id="savejournal" x="11" y="326" width="296" label="Save" click="save()" />

                                                                                          <s:Button id="addphotostojournal" x="11" y="275" width="296" label="Add Photos"/>

                                                                                          <s:Label id="journal" x="10" y="97" color="#E2881E" text="Journal:"/>

                                                                                          <s:Label id="Datefield" x="145" y="97" color="#E2881E" text="Date:"/>

                                                                                          <s:TextInput id="date" x="187" y="78" width="120" height="34" enabled="true" prompt="enter date"/>

                                                                                 

                                                                                 

                                                                                 

                                                                                 

                                                                                </s:View>

                                                                                • 39. Re: New to developing could anyone point me in the right direction for sqlite issue?
                                                                                  JeanneM7289 Level 1

                                                                                  @Peter Elst

                                                                                   

                                                                                  I checked out your link today there is no data on your project.  only text that seems applicable is :

                                                                                   

                                                                                  "This project aims to provide a simple interface to work with local SQLite database with Adobe AIR and provide online/offline synchronization"

                                                                                   

                                                                                  On the main page.  

                                                                                  1 2 Previous Next