Writing to DB using the runPrepStmt

Here is the code I have under a button.

rec = 144 nm = event.source.parent.getComponent('customer name').text num = event.source.parent.getComponent('Customer Number').intValue cod = event.source.parent.getComponent('Numeric Text Field').intValue des = event.source.parent.getComponent('Op Code Desc').text std = event.source.parent.getComponent('Standard').intValue lang = event.source.parent.getComponent('Form Length').floatValue up = event.source.parent.getComponent('Number Up').intValue six = event.source.parent.getComponent('6 by 9').selected stt = event.source.parent.getComponent('stretch').selected nin = event.source.parent.getComponent('9 by 12').selected pin = event.source.parent.getComponent('pinnacles').selected bbs = event.source.parent.getComponent('BBs').selected flw = event.source.parent.getComponent('Flow Masters').selected can = event.source.parent.getComponent('Canadian').selected cd = 0 print rec,nm,num,cod,des,std,lang,up,six,stt,nin,pin,bbs,flw,can,cd fpmi.db.runPrepStmt("INSERT INTO Production_STD_by_Customer (record ,cust_name ,cust_num ,op_code ,op_code_desc ,prod_STD ,form_length ,num_up ,ten_6_by_9 ,stretch ,nine_by_12 ,pinnacles ,BBs ,Flows ,canadian ,code) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?),"[rec,nm,num,cod,des,std,lang,up,six,stt,nin,pin,bbs,flw,can,cd])

I think is it worded correctly and when I check the columns in the DB to what is attemping to be sent there they seem to match, Int for Int, text for varchar, etc… However when I run this code I get the error message TypeError: sequence subscript must be integer or slice. THis seems to indicate that I am attempting to insert in to an int column in the DB a value other than an int. So what part of this code do I have wrong that is causing this error? Thanks for looking and have a great day.

Hmm, It sounds to me like you have a syntax error where you are trying to access a subset of something. ie: “thisisastring”[2:-5]

Try moving the last comma in the string part of the prep statement outside of the "

[code],?,?,?,?,?,?,?,?),"[rec,nm,num,cod,des,

to:

,?,?,?,?,?,?,?,?)",[rec,nm,num,cod,des,[/code]

The line

fpmi.db.runPrepStmt("INSERT INTO Production_STD_by_Customer (record ,cust_name ,cust_num ,op_code ,op_code_desc ,prod_STD ,form_length ,num_up ,ten_6_by_9 ,stretch ,nine_by_12 ,pinnacles ,BBs ,Flows ,canadian ,code) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?),"[rec,nm,num,cod,des,std,lang,up,six,stt,nin,pin,bbs,flw,can,cd])

Should read

fpmi.db.runPrepStmt("INSERT INTO Production_STD_by_Customer (record ,cust_name ,cust_num ,op_code ,op_code_desc ,prod_STD ,form_length ,num_up ,ten_6_by_9 ,stretch ,nine_by_12 ,pinnacles ,BBs ,Flows ,canadian ,code) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",[rec,nm,num,cod,des,std,lang,up,six,stt,nin,pin,bbs,flw,can,cd])

You had the end quote on the query after the comma, it just needs to be before.