SQL INSERT ISSUES

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jobyid
Posts: 4
Joined: Thu Jul 03, 2008 11:25 pm

SQL INSERT ISSUES

Post by jobyid » Fri Jul 04, 2008 3:23 pm

Hi
Again please excuse my lack of knowledge on how to do these things but I am trying to insert data from rev into a SQLite table which i have created.
It all connects ok but I just can't seem to get the data into the table.
I am taking information from a number of fields then trying to but it into the table using a button.
Here is the script I am using for the button;

on mouseUp
Global mydbid
local cname, bal, month, copen, inResult, dplan, inSQL, inResultb
put field "cardnamenew"into cname
put field "add balance"into bal
put field "add month pay"into month
put field "add card opened" into copen
put field "debt plan" into dplan
answer "Are "& cname &", "& bal &", "& month &", "& copen &","& dplan &" correct? " with "yes" or "no"
put it into inResult
put inResult into field "one"
put revOpenDatabase("SQLite",localhost,,,) into mydbid
put "INSERT INTO mydbid, Creditcard(cardname,balance,monthpay,cardopened,debtplan) VALUES("& cname &","& bal &","&month&","& copen &","& dplan &")" into inSQL
revExecuteSQL mydbid, inSQL
put the result into inResultb
if inResultb is not empty then
answer "card entered" else
answer "card not entered"
end if
answer information "Number of cards entered: " & inResultb
end mouseUp

Again thank you very much for any help.

Thanks

joby

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Fri Jul 04, 2008 11:15 pm

Hi Joby,

One of the possible mistakes is that you need quotes around the values:

Code: Select all

quote quote into q
put q & field "cardnamenew" & q into cname
put q & field "add balance" & q into bal
put q & field "add month pay" & q into month
put q & field "add card opened" & q into copen
put q & field "debt plan" & q into dplan
SQLite knows nothing about the database ID used by Rev. I don't think that mydbid belongs in your SQLite syntax.

I'm not compeletely sure, but shouldn't there be spaces after creditcard and VALUES?

You might want to check the INSERT syntax one more time in the SQLite docs, to see whether what I'm saying makes any sense.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

inselfan
Posts: 42
Joined: Fri Nov 10, 2006 11:33 am

Post by inselfan » Sat Jul 05, 2008 8:17 am

Holá Jobyid,

under mySQL I use it like:

put "INSERT INTO Creditcard (cardname,balance,monthpay,cardopened,debtplan) VALUES ('"& cname &"','"& bal &"',"'& month &"','"& copen &"','"& dplan &"')" into inSQL
revExecuteSQL mydbid, inSQL

If this also does not work, figure it out with a SQL-Manager to know exactly WHERE the problem/error is.

Best regards and good luck

Horst

Post Reply