Hi, I am trying to get my button to write up the username and password when clicked, I have this code in the onActionPerformed in script. It is not writing to the database and i checked the connection and thats fine so Ive narrowed it down to the code. I copied the exam given by ignition to a point and made a few of my own changes but does not work, does anyone have any suggestions?
Perspective doesn’t have a Client scope, so all scripting runs on the gateway. The runNamedQuery function requires a project name as the first parameter when run in the Gateway scope.
Hi schenk, I have ran this code but it is still not writing to my database, the “LoginInsert” at the end is the name of my query and isnt in the file path but I added it because I think thats what it says in the example. Any help would be appreciated.
I changed my path as shown below and it worked perfectly.
I had my named query set to the “Update Query” also.
Thanks for your help guys.
# Grab the area number and machine name from the components we added to the window.
Username = self.getSibling("txtUserUsername").props.text
Password = self.getSibling("txtUserPassword").props.text
# A call to our Named Query, inserting the two paramters using dictionary syntax.
#system.db.runNamedQuery("LoginInsert", {"Username":Username, "Password":Password})
system.db.runNamedQuery("FYP", "LoginInsert", {"Username":Username, "Password":Password})
#C:/Program Files/Inductive Automation/Ignition/data/projects/FYP/ignition/named-query