Refreshing database after adding row to table

I’ve made code to add a new row of data to my existing datatable over PostgreSQL and its adding the row successfully but its not refreshing the database. I was wondering what code would be used to refresh the database like clicking on the refresh button on the database query browser. I’ve tried using variations of below. but haven’t figured out to actually get it to refresh. My table name is recipe10 on the postgres (named PostgreSQL) database.

system.db.refresh()

Vision or Perspective?

system.db.refresh() is used in Vision to cause a query binding (and other bindings) to execute again. You must specify the component (table?) and property name that has the binding you wish to re-execute. Those arguments are not optional.

In Perspective, each component has a .refreshBindings() method where you specify the bound property you wish to re-execute.

3 Likes

It’s in vision, I want to reset the entire table to refresh the index after adding a new compete row. So I guess I would need to get the table from the database and run a refresh so the index(and all columns) get added to the table. I’ve tried .getComponent(‘recipe10’) but I may have entered to starting code wrong because I’m trying to get it from the database query.

Where is the code that adds a row? A button component’s actionPerformed event? Something else? Please show your code, your table component’s query binding, and your DB table’s schema.

Basically code pulls it off of screen puts it into the table from what entered into screen by incrementing the index by one. Its attached to a mouse release click button

On line 179 where you call .refresh(), you are supplying recipe10 as a string, where you need to supply it as an actual component. (Using .getComponent().) it isn’t clear from your screen shot what kind of component and what property name is appropriate. Is it a template canvas?

Side notes:

Your method of getting idnew is extraordinarily bad. You should let your database generate one for you and retrieve it with the getKey parameter to system.db.runPrepUpdate().

You are using ‘%’ substitutions for your data in your query. You should be using unquoted ‘?’ substitutions with system.db.runPrepUpdate().

{ Also, in the future, don’t use a screen shot to post code. Paste as plain text, then use the preformatted text button with the code highlighted to make it show neatly as code. }

4 Likes