Database Update

Can someone tell me why the Edit Mode portion of this code won’t work?? The Add Mode portion works just fine, but not the Edit.

[code]varFacilNmbr = event.source.parent.Facility_Number
varProdCodeNmbr = event.source.parent.Prod_code_Nmbr
varProdCode = event.source.parent.getComponent(‘ProductCode’).text
varIng1 = event.source.parent.getComponent(‘Ing1DrpDwn’).selectedLabel
varIng1Pct = event.source.parent.getComponent(‘Ing1_Prcnt’).text

if (varProdCode == “” or varIng1 == “” or varIng1Pct == “”):
system.gui.messageBox(“Please enter Product Parameters”)
else:
if varProdCodeNmbr > 0:
# Edit mode
varProdCodeNmbr = system.db.runPrepUpdate(“UPDATE productcode SET ProductCode, Ing_1, Ing_1_Pct = ?,?,? WHERE idproductcode = ?”,
[varProdCode, varIng1, varIng1Pct, varProdCodeNmbr])
else:
# Add mode
varProdCodeNmbr = system.db.runPrepUpdate(“INSERT INTO productcode (Facility_Nmbr, ProductCode, Ing_1, Ing_1_Pct) VALUES (?,?,?,?)”,
[varFacilNmbr, varProdCode, varIng1, varIng1Pct], getKey=1)

system.nav.closeParentWindow(event)[/code]

Its probably obvious, but I’m sure hung up on it. (Note: Already tried removing the selectedLabel, and that didn’t work either)
Thanks in advance!

Try something like:

varProdCodeNmbr = system.db.runPrepUpdate("UPDATE productcode SET ProductCode=?, Ing_1=?, Ing_1_Pct = ? WHERE idproductcode = ?", [varProdCode, varIng1, varIng1Pct, varProdCodeNmbr])

providing some degree of separation may help resolve that.

Jordan,
That minor modification that you suggested made all the difference in the world. Thanks a million! :wink:

No problem. As with most things programatical, it does what we tell it to do, not what we want it to do… :laughing: