I hope some expert could help me with the problem below. Thanks a lot if you could help.
I am new to Livecode DataGrid and I am exploring how to insert data in the DataGrid to MYSQl database.
I encountered the following error message:
Following is my script:You have an error in your SQL syntax check the manual that correspond to your MYSQL server version
for the right syntax to use near 'desc) values ('2') at line 1
Global gConnectionID
on MouseUP
databaseConnect
## Get Data Grid Array
put the dgData of group "dg1" into theDataA
## Get indexes in proper order
put the dgIndexes of group "dg1" into theIndexes
-- edit these variables to match your database & table
put "test" into tTableName
put "ln, desc" into tFields
-- construct the SQL - the :1, :2 & :3 placeholders in the SQL will be filled by variables in the revExecuteSQL line
repeat for each item theIndexes in theIndexes
put theDataA[theIndexes]["ln"] into tln
put theDataA[theIndexes]["desc"] into tdesc
end repeat
put "INSERT INTO " & tTableName & " (" & tFields & ") VALUES (:1, :2)" into tSQL
revExecuteSQL gConnectionID, tSQL, "tln", "tdesc"
-- check the result and display the data or an error message
if the result is a number then
answer info "New record added."
else
answer error "There was a problem adding the record to the database:" & cr & the result
end if
end mouseUp