Page 1 of 1

SQLite Data between Stacks

Posted: Wed Jul 31, 2013 3:54 pm
by gpearson
As I learn Livecode, I have been creating an application that I wrote in Adobe Air/Flash/Flex. This application has been ported to Livecode as a single stack which now I am rewriting it to include a method of updating it by splitting the stack into 2 stacks. The first stack is the Splash Screen Stack which handles the application registration, creating database tables, populating the database, downloading the Main Application Stack, checking versions between online website and current version on computer. The second stack has the rest of the application which takes the information from the database and displays icons on a Google Map.

My question is with the second stack. I am getting 0 records returned when executing the following code on tSelectMarketRecordCount. If I use an SQLite Viewer attached to the same SQLite database file with the tSelectMarketsSQL I get 23 records returned. If I change my original stack to use the same SQLite database file that this updated version of the application uses, I get 23 records.

Code: Select all

put "Select MarketID, CallSign, City, State, BTALatitude, BTALongitude from Markets Order by State ASC, City ASC" into tSelectMarketsSQL
put the value of revQueryDatabase(sDatabaseID, tSelectMarketsSQL) into tSelectMarketsRecordSetID
put the value of revNumberOfRecords(tSelectMarketsRecordSetID) into tSelectMarketRecordCount
In the first stack right before I goto the main stack I close the database connection and on the preOpenCard of the second stack I run a command to ConnectDatabase. I get an interger value on tSelectMarketsRecordSetID and an integer on sDatabaseID. I am just not sure what steps I can do to view why the revNumberOfRecords is returning a 0.

Any Suggestions

Re: SQLite Data between Stacks

Posted: Sat Aug 03, 2013 1:33 am
by dave.kilroy
Graham

First of all have you included the database library for your second stack?

What happens if you try:
put revQueryDatabase(sDatabaseID, tSelectMarketsSQL) into tSelectMarketsRecordSetID
instead of:
put the value of revQueryDatabase(sDatabaseID, tSelectMarketsSQL) into tSelectMarketsRecordSetID

Can you use something like revOpenDatabases() to check which databases are open? Are you sure you are connecting to the same db from both stacks? Compare the connection strings used by both stacks. Use something like exists() to make sure your second database is opening an existing db and not creating a new one (which I will do if not one present)

check your table name with revDatabaseTableNames() and column names with revDatabaseColumnNames()

confirm contents of database after creation and population by your launcher stack with something independent of your code/stacks like SQLiteManager

Try a simplified query using * instead of named columns and without an ORDER BY component to it.

That's all I can think of for now - let us know how you get on...

Dave

Re: SQLite Data between Stacks

Posted: Tue Aug 06, 2013 11:22 am
by MaxV
My two cents experience is to write code this way:

Code: Select all

put "Select MarketID, CallSign, City, State, BTALatitude, BTALongitude from Markets Order by State ASC, City ASC" into tSelectMarketsSQL
put  revDataFromQuery(TAB,return,sDatabaseID, tSelectMarketsSQL) into tSelectMarketsRecordSetID
put the numbers of lines of tSelectMarketsRecordSetID into tSelectMarketRecordCount
Does it work?

Re: SQLite Data between Stacks

Posted: Tue Aug 06, 2013 2:10 pm
by gpearson
I am working on getting the License straight as I have discovered that the when I activate a new version of LC I am only licensed for the Desktop versions. Once I get this resolved, I will be able to move forward on this. Many good examples of code is here and I mgiht be able to improve the speed of my queries/SQL as I will try each one of these.