Problems with UPDATE on a MySQL db

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: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
hefreeman-gmail
Posts: 2
Joined: Mon Nov 09, 2020 6:04 pm

Problems with UPDATE on a MySQL db

Post by hefreeman-gmail » Mon Nov 09, 2020 6:10 pm

Hi all,
I'm having real issues with the UPDATE command on a MySQL database. I can connect to the db via a website and via a filemaker db via ODBC. The code I have for updating in livecode doesn't throw an error but nor does it update the database.
Here's the code:

answer gConnectionID

put "cemdata" into tTableName

put field "indexcd" into tindexcd
put field "surname" into tsurname
put field "firstname" into tfirstname
put field "datedied" into tdatedied
put field "section" into tsection
put field "gravenum" into tgravenum
put field "gravecol" into tgravecol
put field "graverow" into tgraverow
put field "dateborn" into tdateborn
put field "maiden" into tmaiden
put field "additional1" into tadditional1

put "UPDATE " & tTableName & " SET " && \
"surname = '" & tsurname & "'," && \
"firstname = '" & tfirstname & "'," && \
"datedied = '" & tdatedied & "'," && \
"section = '" & tsection & "'," && \
"gravenum = '" & tgravenum & "'," && \
"gravecol = '" & tgravecol & "'," && \
"graverow = '" & tgraverow & "'," && \
"dateborn = '" & tdateborn & "'," && \
"maiden = '" & tmaiden & "'," && \
"additional1 = '" & tadditional1 & "'," && \
"WHERE indexcd = '" & tindexcd & "'" \
into tSQLstatement

answer tSQLstatement
revExecuteSQL gConnectionID, tSQLstatement

The tSQLstatement comes out as well formed, no errors apparent but no update! Any ideas??
Thanks

hefreeman-gmail
Posts: 2
Joined: Mon Nov 09, 2020 6:04 pm

Re: Problems with UPDATE on a MySQL db SOLVED!

Post by hefreeman-gmail » Mon Nov 09, 2020 6:21 pm

Just one comma, no error but no action!!

Here's the last part of the statement:

"additional1 = '" & tadditional1 & "'," && \
"WHERE indexcd = '" & tindexcd & "'" \

The comma before the 'WHERE' was messing up the code. I removed the comma, all is now well. Just posting it here made me look more carefully at the code.

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”