Q:SQLIte on IOS, database not found (SOLVED)

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Informatie
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 37
Joined: Fri Sep 09, 2011 10:04 am
Location: Netherlands

Q:SQLIte on IOS, database not found (SOLVED)

Post by Informatie » Fri Nov 25, 2011 8:51 pm

I was working on a simple app with sqlite.
The problem is when I browse the IOS file system on my ipad I can see the the database file is located in the documents direcotory
I simplified the code :
put specialFolderPath("documents") & "/shapdata.dbf" into tMainStackPath
put specialFolderPath("engine") & "/shapdata.dbf" into tOriginalStackPath
put url ("binfile:" & tOriginalStackPath) into url ("binfile:" & tMainStackPath)

however when I try to read the database NONE of the table can be found. In the LC env it works fine. But on the IOS simulator and the IPAD itseld the database cannot be found. I have the feeling i'm allmost there.

What do I have to set ?
Last edited by Informatie on Wed Nov 30, 2011 9:01 pm, edited 1 time in total.

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am
Location: Bordeaux, France

Re: Q:SQLIte on IOS, database not found

Post by Dixie » Fri Nov 25, 2011 10:25 pm

Hi...

Here is a 'snip' from one of my stacks that I use to open a SQLite database...

Code: Select all

      set the defaultfolder to specialFolderPath("documents")
      
 if there is a file "localKnow.db" then
    put revOpenDatabase("sqlite","localKnow.db",,,,) into gDataBaseRef
    get revDataFromQuery (tab, return , gDataBaseRef, "SELECT * FROM towns;" )
    put it into theData
    revCloseDataBase gDatabaseRef
else
Maybe, it will give you an idea about what you want to do...

Dixie

Informatie
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 37
Joined: Fri Sep 09, 2011 10:04 am
Location: Netherlands

Re: Q:SQLIte on IOS, database not found

Post by Informatie » Sat Nov 26, 2011 10:56 am

thx dixie i give it a try.


DJ

Informatie
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 37
Joined: Fri Sep 09, 2011 10:04 am
Location: Netherlands

Re: Q:SQLIte on IOS, database not found

Post by Informatie » Sun Nov 27, 2011 5:45 pm

Brr niceit's working in the IOS simulator now, I see the data.
But when I run the application on the ipad the datafield remain empty.

I tried the statement with and without the ; both options are failing on the ipad.

revebderr , database error no such table DJAN

on mouseUp
set the defaultfolder to specialFolderPath("documents")
put revOpenDatabase("sqlite","shapdata.dbf",,,,) into gDataBaseRef
-- fails get revDataFromQuery (tab, return , gDataBaseRef, "SELECT * FROM DJAN;" )
-- fails get revDataFromQuery (tab, return , gDataBaseRef, "SELECT * FROM DJAN" )
-- fails get revDataFromQuery (tab, return , gDataBaseRef, "SELECT * FROM djan" )
-- fails get revDataFromQuery (tab, return , gDataBaseRef, "SELECT * FROM djan;" )
put it into field "fld_klanten" ---klanten = customers
revCloseDataBase gDatabaseRef
end mouseUp

i checked and checked the database which was included in the copyfile option. the location is documents.

special settings ?

Cheers DJ

Informatie
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 37
Joined: Fri Sep 09, 2011 10:04 am
Location: Netherlands

Re: Q:SQLIte on IOS, database not found

Post by Informatie » Wed Nov 30, 2011 3:56 pm

on mouseUp
try
set the defaultfolder to specialFolderPath("documents")

put "shapdata.dbf" into pathNdb
put revOpenDatabase("sqlite", pathNdb,,,,,,) into gConID
catch theError
answer info "Problem Opening Database: " & pathNdb & " " & theError
put 0 into gConID
exit mouseup
end try
answer information "Connected to: " & pathNdb & " ID is: " & gConID
try
get revDataFromQuery (tab, return , gConID, "SELECT * FROM DJAN;" )
put it into field "fld_klanten"
catch therror
answer info "error 2 " & pathNdb & " " & theError
exit mouseup
end try
end mouseup

On IOS it says database found but not the table ????
who has the hint for me.

dj

Informatie
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 37
Joined: Fri Sep 09, 2011 10:04 am
Location: Netherlands

Re: Q:SQLIte on IOS, database not found (SOLVED)

Post by Informatie » Wed Nov 30, 2011 9:00 pm

dixie helped me thks.

SOLUTION FOR ME

set the defaultfolder to specialFolderPath("documents")
if there is a file "shapdata.dbf" then
put revOpenDatabase("sqlite", pathNdb,,,,,,) into gConID
else
put specialFolderPath("documents") & "/shapdata.dbf" into tMainStackPath
put specialFolderPath("engine") & "/shapdata.dbf" into tOriginalStackPath
put url ("binfile:" & tOriginalStackPath) into url ("binfile:" & tMainStackPath)
put revOpenDatabase("sqlite", pathNdb,,,,,,) into gConID
end if

my db actions;

NOTE : the database file (shapdata.dbf) is add in the copy files, further general database support check and sqlite and on the IOS I check sqlite.


dj

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Q:SQLIte on IOS, database not found (SOLVED)

Post by Klaus » Wed Nov 30, 2011 9:35 pm

Where is the difference to your initial script?
There you also copied the database file from ENGINE to DOCUMENTS! :shock:

Informatie
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 37
Joined: Fri Sep 09, 2011 10:04 am
Location: Netherlands

Re: Q:SQLIte on IOS, database not found (SOLVED)

Post by Informatie » Fri Dec 02, 2011 9:02 pm

Klaus there is a difference that I forgot to check if a file exists. so I replaced the file everytime.
dixie didn't include the copy part but the check exists part.

so the fix for me was that I had all the right command's but not in the right order. to obvious perhaps :roll:
By way the the next steps is moving a cursor in the master recordset and show the related detail recordset.

DJ

Post Reply

Return to “iOS Deployment”