I have a button within a program that adds a row to a table in the program after data has been entered into corresponding text fields, and the code looks like this:
[code]string = event.source.parent.getComponent(‘Group’).getComponent(‘Text Field’).text
string2 = event.source.parent.getComponent(‘Group’).getComponent(‘Text Field 1’).text
string3 = event.source.parent.getComponent(‘Group’).getComponent(‘Text Field 3’).text
string4 = event.source.parent.getComponent(‘Group’).getComponent(‘Text Field 2’).text
string5 = event.source.parent.getComponent(‘Group’).getComponent(‘Text Area’).text
number = event.source.parent.getComponent(‘Group’).getComponent(‘Numeric Text Field’).intValue
table = event.source.parent.getComponent(‘Table’)
newRow = [string, string2, number, string3, string4, string5]
table.data = system.dataset.addRow(table.data, newRow)
event.source.parent.getComponent(‘Group’).getComponent(‘Text Field’).text = ‘’
event.source.parent.getComponent(‘Group’).getComponent(‘Text Field 1’).text = ‘’
event.source.parent.getComponent(‘Group’).getComponent(‘Text Field 2’).text = ‘’
event.source.parent.getComponent(‘Group’).getComponent(‘Text Field 3’).text = ‘’
event.source.parent.getComponent(‘Group’).getComponent(‘Text Area’).text = ‘’
event.source.parent.getComponent(‘Group’).getComponent(‘Numeric Text Field’).intValue = 0[/code]
Is there a way that I can add this code to a table within a table in a database? My thought was then I would just be able to tie the table to a DB query and the table would update like it currently does, but with a SQL table, I would be able to manipulate the data easier in order to say sort and display data using a dropdown menu.
So bottom line question is can i add rows to a SQL table the same way I add a row to a table within ignition?