# Problem with DB Update Script

**URL:** <https://forum.inductiveautomation.com/t/problem-with-db-update-script/7484>\
**Category:** General Discussion\
**Created:** [October 28, 2013, 9:33pm UTC](https://forum.inductiveautomation.com/t/problem-with-db-update-script/7484 "2013-10-28T21:33:00Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![cire3621](https://avatars.discourse-cdn.com/v4/letter/c/f08c70/32.png) [@cire3621](https://forum.inductiveautomation.com/u/cire3621)\
**Post date:** [October 28, 2013, 9:33pm UTC](https://forum.inductiveautomation.com/t/problem-with-db-update-script/7484/1 "2013-10-28T21:33:00Z")

</div>

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])  
[/code]

---

<div class="post-metadata">

**Author:** ![george](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/george/32/14066_2.png) [@george](https://forum.inductiveautomation.com/u/george)\
**Post date:** [October 28, 2013, 9:53pm UTC](https://forum.inductiveautomation.com/t/problem-with-db-update-script/7484/2 "2013-10-28T21:53:38Z")

</div>

Where you have VALUE it should be VALUES

---

<div class="post-metadata">

**Author:** ![adamaustin](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@adamaustin](https://forum.inductiveautomation.com/u/adamaustin)\
**Post date:** [October 28, 2013, 9:56pm UTC](https://forum.inductiveautomation.com/t/problem-with-db-update-script/7484/3 "2013-10-28T21:56:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cire3621](https://avatars.discourse-cdn.com/v4/letter/c/f08c70/32.png) [@cire3621](https://forum.inductiveautomation.com/u/cire3621)\
**Post date:** [October 28, 2013, 9:58pm UTC](https://forum.inductiveautomation.com/t/problem-with-db-update-script/7484/4 "2013-10-28T21:58:34Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![cire3621](https://avatars.discourse-cdn.com/v4/letter/c/f08c70/32.png) [@cire3621](https://forum.inductiveautomation.com/u/cire3621)\
**Post date:** [October 28, 2013, 10:01pm UTC](https://forum.inductiveautomation.com/t/problem-with-db-update-script/7484/5 "2013-10-28T22:01:36Z")

</div>

customer  
first  
last

I have set for VARCHAR

card  
pin

I have set for Int

---

<div class="post-metadata">

**Author:** ![adamaustin](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@adamaustin](https://forum.inductiveautomation.com/u/adamaustin)\
**Post date:** [October 28, 2013, 10:08pm UTC](https://forum.inductiveautomation.com/t/problem-with-db-update-script/7484/6 "2013-10-28T22:08:19Z")

</div>

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](http://www.w3schools.com/sql/sql_alter.asp) your column for the card because an INT can not store the credit card info (16 digits). (The same is true for [MySQL](http://dev.mysql.com/doc/refman/5.5/en/integer-types.html) and [MS SQL](http://technet.microsoft.com/en-us/library/ms187745.aspx).)

---

<div class="post-metadata">

**Author:** ![cire3621](https://avatars.discourse-cdn.com/v4/letter/c/f08c70/32.png) [@cire3621](https://forum.inductiveautomation.com/u/cire3621)\
**Post date:** [October 28, 2013, 10:14pm UTC](https://forum.inductiveautomation.com/t/problem-with-db-update-script/7484/7 "2013-10-28T22:14:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![adamaustin](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@adamaustin](https://forum.inductiveautomation.com/u/adamaustin)\
**Post date:** [October 28, 2013, 10:21pm UTC](https://forum.inductiveautomation.com/t/problem-with-db-update-script/7484/8 "2013-10-28T22:21:39Z")

</div>

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):

![](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/f/ef6326aef193d4eae80a59a983f3a539d763c7ac.jpeg)

---

<div class="post-metadata">

**Author:** ![cire3621](https://avatars.discourse-cdn.com/v4/letter/c/f08c70/32.png) [@cire3621](https://forum.inductiveautomation.com/u/cire3621)\
**Post date:** [October 28, 2013, 10:31pm UTC](https://forum.inductiveautomation.com/t/problem-with-db-update-script/7484/9 "2013-10-28T22:31:46Z")

</div>

That’s how it has been…

![]()

---

<div class="post-metadata">

**Author:** ![adamaustin](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@adamaustin](https://forum.inductiveautomation.com/u/adamaustin)\
**Post date:** [October 28, 2013, 10:54pm UTC](https://forum.inductiveautomation.com/t/problem-with-db-update-script/7484/10 "2013-10-28T22:54:53Z")

</div>

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.
