Q:SQLIte on IOS, database not found (SOLVED)
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 37
- Joined: Fri Sep 09, 2011 10:04 am
- Location: Netherlands
Q:SQLIte on IOS, database not found (SOLVED)
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 ?
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.
-
- Livecode Opensource Backer
- Posts: 1336
- Joined: Sun Jul 12, 2009 10:53 am
- Location: Bordeaux, France
Re: Q:SQLIte on IOS, database not found
Hi...
Here is a 'snip' from one of my stacks that I use to open a SQLite database...
Maybe, it will give you an idea about what you want to do...
Dixie
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
Dixie
-
- VIP Livecode Opensource Backer
- Posts: 37
- Joined: Fri Sep 09, 2011 10:04 am
- Location: Netherlands
Re: Q:SQLIte on IOS, database not found
thx dixie i give it a try.
DJ
DJ
-
- VIP Livecode Opensource Backer
- Posts: 37
- Joined: Fri Sep 09, 2011 10:04 am
- Location: Netherlands
Re: Q:SQLIte on IOS, database not found
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
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
-
- VIP Livecode Opensource Backer
- Posts: 37
- Joined: Fri Sep 09, 2011 10:04 am
- Location: Netherlands
Re: Q:SQLIte on IOS, database not found
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
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
-
- 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)
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
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
Re: Q:SQLIte on IOS, database not found (SOLVED)
Where is the difference to your initial script?
There you also copied the database file from ENGINE to DOCUMENTS!
There you also copied the database file from ENGINE to DOCUMENTS!
-
- 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)
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
By way the the next steps is moving a cursor in the master recordset and show the related detail recordset.
DJ
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
By way the the next steps is moving a cursor in the master recordset and show the related detail recordset.
DJ