Page 1 of 1

SQLite connection

Posted: Fri Mar 28, 2014 9:47 pm
by jpyck
Hi,
I followed the code from the example in lesson 3.
When connecting to the SQLite (contacts.sqlite) database (which is located in the "documents" folder in Win 8) I get this error message:
"revdberr,Database Error: near "tSQLQuery": syntax error"

Any ideas? Thanks.

Here is the code for the card "contacts":

local sDatabaseConnectionID


on preOpenCard
# mobGUIStart ---> Inserted by mobGUI plugin
if "MobGUILib-1394918029138" is not among the lines of the stacksInUse then start using stack "MobGUILib-1394918029138"
mobGUIPreOpenCard me
# mobGUIEnd
set the utext of group "title" to "contacts"
end preOpenCard


on databaseConnect pType
if pType is "SQLite" then
put specialFolderPath("documents") & "/contacts.sqlite" into tDatabasePath
put revOpenDatabase ("sqlite",tDatabasePath,,,) into sDatabaseConnectionID
else if pType is "Direct MySQL" then

else if pType is "Web MySQL" then

end if

end databaseConnect

on databaseSelectAllNames
if the uOptionText of group "databaseType" is "SQLite" or the uOptionText of group "databaseType" is "Direct MySQL" then
put empty into field "contacts"
put "SELECT firstname,lastname,contact_id FROM contacts" into tQSLQuery
put revDataFromQuery(comma,return,sDatabaseConnectionID,tSQLQuery) into tContacts
put tContacts into field "contacts"
end if

end databaseSelectAllNames

Re: SQLite connection

Posted: Sat Mar 29, 2014 12:47 am
by SparkOut
The line

put "SELECT firstname,lastname,contact_id FROM contacts" into tQSLQuery

has the tSQLQuery variable name spelled wrongly. Is that just a copying typo? or ... I think that's possibly your issue. tSQLQuery will be empty so revDataFromQuery will try to run an empty query and fail.

Re: SQLite connection

Posted: Sat Mar 29, 2014 3:08 am
by jpyck
Thanks Sparkout, that was it. I must have stared at it too long...a second pair of eyes always works.
Jack