Problem with DB Update Script

I have created a form with 5 fields and a submit button to update my database table with user entered data. The fields are customer, first, last, card, pin that data can be input to…but I keep getting errors when i execute the script…is their something wrong with the following script that I am missing?

[code]customer = event.source.parent.getComponent(“customer”).text
first = event.source.parent.getComponent(“first”).text
last = event.source.parent.getComponent(“last”).text
card = event.source.parent.getComponent(“card”).intValue
pin = event.source.parent.getComponent(“pin”).intValue

system.db.runPrepUpdate(“INSERT INTO customers (customer, first, last, card, pin) VALUE (?,?,?,?,?)”, [customer, first, last, card, pin])

Where you have VALUE it should be VALUES

Also, make sure that your card field is a BIGINT or VARCHAR/NVARCHAR.

Yea the VALUES didnt make much of a difference but I was trying to just pull in one field and it wouldnt even do that so i just added all the fields back and forgot to add S back to VALUE…This is the error I am getting.

Traceback (most recent call last):

File “event:mouseReleased”, line 1, in

AttributeError: ‘NoneType’ object has no attribute ‘text’

Am I just doing something completely wrong? Somewhere else?


I have set for VARCHAR


I have set for Int

The error you are getting is because you misspelled the component name for “customer” (the error is on line 1). Because you are not getting the component (it is returning None instead of the component), there is nothing to get the text part of. Make sure your text for the component name is case-sensitive, just in case that might be the problem.

You’ll have to ALTER your column for the card because an INT can not store the credit card info (16 digits). (The same is true for MySQL and MS SQL.)

Well the Card and Pin Number are 5 digit numbers they are from an RF Reader and a 5 digit pin number will be issued as well. Basically it is customer, first name, last name, card number, pin number. I am using MySQL. The names of the fields are customer, first, last, card, pin. The database is called customers, and the table columns are customer, first, last, card, pin. And it still is giving me an error?

Sorry i meant the Database is called Cooper the table is called customers.

Make sure all your components in Ignition Designer are named correctly. Also make sure they are all under the Root Container (or at least at the same level of grouping as your Button):

That’s how it has been…

I was only able to recreate your problem by renaming my text field to "customer " (that’s a space that you can not see in the Project Browser. Rename your “customer” text field again.

By the way, those fields for card and pin look like text fields which will give you a problem when you try to get the intValue of them. Just use text and the runPrepUpdate should take care of the rest.

Hmm, but if you used a custom property it will work just fine. OK, ignore me.