Why am I using runPrepUpdate incorrectly?

This gives me the old syntax error. (on the last line)

[quote]# get new value
value = event.newValue

get row for new value (local table)

row = event.row

get column for new value in local table

col = event.column

get selected column name for db update

data = event.source.data
colname = data.getColumnName(col)

get ID for database update

IDnum = data.getValueAt(row,“ID”)
#change DB to reflect edited table
system.db.runPrepUpdate(“UPDATE stimprogram SET ?=? WHERE ID=?”,[colname,value,IDnum], “CHCFG”[/quote]

The column name cannot be mapped using the question character.

Try this:

query = "UPDATE stimprogram SET %s=? WHERE ID=?" % (colname)
system.db.runPrepUpdate(query, [value,IDnum], "CHCFG")

Thanks, that worked. :prayer:

1 Like

Glad that been worked. :thumb_left:

Please, mark this topic as solved.