# Update db table B from table A with button press

**URL:** <https://forum.inductiveautomation.com/t/update-db-table-b-from-table-a-with-button-press/29277>\
**Category:** Ignition\
**Tags:** ignition79\
**Created:** [October 22, 2019, 1:31pm UTC](https://forum.inductiveautomation.com/t/update-db-table-b-from-table-a-with-button-press/29277 "2019-10-22T13:31:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![boster281](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@boster281](https://forum.inductiveautomation.com/u/boster281)\
**Post date:** [October 22, 2019, 1:31pm UTC](https://forum.inductiveautomation.com/t/update-db-table-b-from-table-a-with-button-press/29277/1 "2019-10-22T13:31:40Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/9/946e3cc4d09569285e02abc5ce93835f6de9092e.png)

The top table is table A and the bottom is table B.  
On table B I have polling turned off.  
On table A I am coping table B and have editable rows  
I edit table A the press the button and it moves the data into table B where I have an update on cell edit  
Code as follows

```auto
database = event.source.parent.parent.DatabaseConnection
sequencetable = event.source.parent.parent.SequenceTable
connection = "["+database+"].[dbo].["+sequencetable+"]"
table = event.source.parent.getComponent('Table')
if table.selectedRow != -1:
	ndx = event.source.parent.Key_Ndx
	columnname = table.data.getColumnName(table.selectedColumn)
	value = table.data.getValueAt(table.selectedRow, table.selectedColumn)
	print connection
	query = "UPDATE "+connection+" SET "+columnname+" = ? WHERE Key_Ndx = ?"
	system.db.runPrepUpdate(query,[value, ndx])

```

But it won’t update.

The reason I want to do it this way is to force notes to be taken and be able to edit an entire table at once.
