John,

The standalone "copy files" are in "the engine folder" in the mobile app.
Copy the DB from the engine folder to the documents folder.

Put url ("binfile:"&the engine folder&"/ccssdb-ela.sqlite") into url 
("binfile:"&the documents folder&"/ccssdb-ela.sqlite")

You can't open the DB in the engine folder even if you don’t try to write to it 
as the engine folder is read-only.

Ralph DiMola
IT Director
Evergreen Information Services
rdim...@evergreeninfo.net


-----Original Message-----
From: use-livecode [mailto:use-livecode-boun...@lists.runrev.com] On Behalf Of 
JOHN PATTEN via use-livecode
Sent: Thursday, April 20, 2017 1:38 PM
To: How to use LiveCode
Cc: JOHN PATTEN
Subject: Error connecting to SQLlite in iOS

Hi All,

I have a simple project that uses an sql lite database. It works fine in 
LiveCode, but when I test it in the iOS simulator, i get an error.

I have copied to the SQL.lite database to the “Copy Files” in the standalone 
settings. I have also added the SqLite and MySQL inclusions.

Here is the link to the project and db: Here is a link to the stack and sql db: 
 https://www.dropbox.com/s/74rhx88dod6cs2k/CCSS%20App.zip?dl=0 
<https://www.dropbox.com/s/74rhx88dod6cs2k/CCSS%20App.zip?dl=0>

Here is the script I am using.

local sDatabaseID

command databaseConnect
local tDatabasePath, tDatabaseID

     put specialFolderPath("Documents") &  "/ccssdb-ela.sqlite" into 
tDatabasePath

## Test if a database exists

if there is a file tDatabasePath then

answer "A database already exists" with "Okay"

end if

if there is a file tDatabasepath then
put  revOpenDatabase("sqlite", tDatabasePath, , , , ) into tDatabaseID 
setDatabaseID tDatabaseID

put cd fld "targetGrade" into tGrade

if tGrade is 10 then

put 9 into tGrade

end if

if tGrade is 12 then

put 11 into tGrade

end if

put revQueryDatabase(tDatabaseID,"SELECT * FROM ccss_data WHERE grade 
=:1","tGrade") into theCursor

if theCursor is an integer then

ConvertSQLCursorToArray theCursor, theDataGridArray

put the result into theError

if theError is empty then

set the dgData of group "ccss_data" to theDataGridArray

end if

revCloseCursor theCursor


revCloseDatabase tDatabaseID

else


Answer "Error connecting to the database:" && tDatabaseID & "."
end if


else

Answer "Having trouble locating database."

end if

end DatabaseConnect

command setDatabaseID pDatabaseID

  put pDatabaseID into sDatabaseID

end setDatabaseID


function getDatabaseID

  return sDatabaseID

end getDatabaseID


command ConvertSQLCursorToArray pCursor, @pOutArrayA

local i

local theFields

local theError


put revDatabaseColumnNames(pCursor) into theFields

if theFields begins with "revdberr," then

put item 2 to -1 of theFields into theError

end if

if theError is empty then

put 0 into i

repeat until revQueryIsAtEnd(pCursor)

add 1 to i


repeat for each item theField in theFields

put revDatabaseColumnNamed(pCursor, theField) into pOutArrayA [i] [theField]

end repeat


revMoveToNextRecord pCursor

end repeat

end if

return theError

end ConvertSQLCursorToArray


Thank you!

_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to