I am using below script which is bind to button component. If button clicked, update query is not working.Just for checking I tried insert, that was working fine! Below is my code.
i=self.view.params.row_id
system.db.runPrepUpdate("INSERT INTO drawing_master (name, drawingno, product) VALUES (?,?,?)", [self.parent.parent.getChild("FlexContainer_0").getChild("Name_text").props.text, self.parent.parent.getChild("FlexContainer_0").getChild("drawing_no_text").props.text, self.parent.parent.getChild("FlexContainer_1").getChild("TextField").props.text])
system.db.runPrepUpdate("UPDATE drawing_master SET name = ?, drawingno = ?,product = ? WHERE id = ?",[self.parent.parent.getChild("FlexContainer_0").getChild("Name_text").props.text,self.parent.parent.getChild("FlexContainer_0").getChild("drawing_no_text").props.text,self.parent.parent.getChild("FlexContainer_1").getChild("TextField").props.text,i])
Table data is not getting updated. My DB is MYSQL. Kindly help me to resolve this. I was stuck.
There is no error i am facing!
Table Definition:
"CREATE TABLE drawing_master (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(50) NOT NULL,
drawingno VARCHAR(50) NOT NULL,
product VARCHAR(100) NOT NULL
);"
Is any of the data NULL? You may want to print out all your data to the web browser console using system.perspective.print and verify that you don't have any NULL data that you are trying to update.
Also.. if you can insert but not update with the data, it might be that this
i=self.view.params.row_id
isn't returning the data you think it is. Inspect that data as well in the console.
Side note... rather than using the relative paths, you may want to have your components be bound to custom properties and use those instead. Just in case you decide to move things.
Thank you for your input. Now it is working.
Corrected Code:
system.db.runPrepUpdate("UPDATE drawing_master SET name = ?, drawingno = ?,product = ? WHERE id = ?",[self.parent.parent.getChild("FlexContainer_0").getChild("Name_text").props.text,self.parent.parent.getChild("FlexContainer_0").getChild("drawing_no_text").props.text,self.parent.parent.getChild("FlexContainer_1").getChild("TextField").props.text,self.view.params.row_id])