unrecognized token: ":" in sqlight statement

new BookmarkLockedFalling
glscottmcsa
New Member
*

glscottmcsa Avatar

Posts: 4

Post by glscottmcsa on Mar 10, 2019 9:25:29 GMT -5

What do I need to change to not get this nasty error?


a$="1":b$="2":c$="3"$="4":e$="5"
sqliteconnect #records, "c:\rbp101\PPeople.db"
query$ = "Insert into c:\rbp101\PPeople.db (Last, First, Pref, Email, Phone) values ("
query$ = query$ + chr$(34) + chr$(34) + a$ + chr$(34) + chr$(34) + "," + chr$(34) + chr$(34) + b$ + chr$(34)
query$ = query$ + chr$(34) + "," + chr$(34) + chr$(34) + c$ + "," + chr$(34) + chr$(34) + d$
query$ = query$ + chr$(34) + chr$(34) + "," + chr$(34) + chr$(34) + e$ + chr$(34) + chr$(34) + ")"
print query$
#records execute(query$)
[ /pre]

this produces:

Runtime Error in program 'just a test': #records execute(query$)
unrecognized token: ":"
I used the print query$ to make sure I had to correct amount of quotes
StefanPendl
Global Moderator
*****

StefanPendl Avatar

Run for BASIC ...
Posts: 945

Post by StefanPendl on Mar 10, 2019 14:23:35 GMT -5

The problem is the path to the DB file used by the insert command, this should be replaced by the name of a table. I would suggest rereading the SQLite help about the insert command.
In addition, to simplify the code, you can use single quotes instead of double ones.

a$="1":b$="2":c$="3":d$="4":e$="5"
sqliteconnect #records, "c:\rbp101\PPeople.db"
query$ = "Insert into MyTable (Last, First, Pref, Email, Phone) values ("
query$ = query$ + "'" + a$ + "','" + b$ + "','" + c$ + "','" + d$ + "','" + e$ + "')"
print query$
#records execute(query$)
[b]Stefan[/b] - [a href=http://stefanpendl.runbasichosting.com/]Homepage[/a][br][br][b]Please give credit if you use code I post, no need to ask for permission.[/b][br][br]Run BASIC 1.01, Fire-/Waterfox (IE11, Edge), Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM