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
SQL INSERT ISSUES
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Hi Joby,
One of the possible mistakes is that you need quotes around the values:
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
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
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
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
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
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