Code: Select all
global gConnectionID
on mouseUp
-- check the global connection ID to make sure we have a database connection
if gConnectionID is not a number then
answer error "Please connect to the database first."
exit to top
end if
-- edit these variables to match your database & table
-- this assumes a table called Table1 with 3 fields
put "Persons" into tTableName
put "UserName, HighScore" into tFields
#put "Elanor" into tFirstName
put field "Try" into tFirstName
put field "Score" into tLastName
#put the short date into tBirthDate -- this is nonsensical but gives some variation to the data
-- construct the SQL - the :1, :2 & :3 placeholders in the SQL will be filled by variables in the revExecuteSQL line
#put "INSERT INTO " & tTableName & " (" & tFields & ") VALUES (:1, :2)2 into tSQL
#put "UPDATE " & tTableName & " SET HighScore= " " VALUE (:1)" " WHERE UserName= " "VALUE (:2)" into tSQL
put "UPDATE " & tTableName & " SET HighScore= " & " VALUE (:1) " & "WHERE UserName=" & " VALUE (:2)" into tSQL
-- send the SQL to the database, filling in the placeholders with data from variables
revExecuteSQL gConnectionID, tSQL, "tLastName", "tFirstName"
-- 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
(the error is given on a popup message saying to check the sql syntax, it seems okay to me...)
thanks!