hub.eb?material_id=121

Database resources


A database resource is Verj.io's easy way of connection your app to your database. Once connected you can move data in and out under program control. 

Steps


1

Create a new Database Resource by using the Resources Wizard under Tools.

 

2

Choose the EBASE_SAMPLES database and select the EBASE_SAMPLES schema. 

Select the PETS table.

3

Check Tables Only and untick Columns for Where Clause.

We do this because we want to bring all the data rather than a particular row ID by the table's primary key. 

4

Your new database resource should open automatically.

5

Create a new form and call it myPets

6

In the Resources tab on the right hand side of the form, add your PETS database resource.

7

Add a table to the Tables tab

Select your PETS resource and import the DESCRIPTION, ID and NAME columns (you can do this by holding down the CTRL key when selecting).

The columns you have selected auto map to your table columns. Mappings allow your app to move data in and out of the database.

You can view your mappings by clicking the Mappings button in the Resources tab.

8

Drag your new table onto your form from the tab. Delete the ID column and set the number of columns to be 0.

9

Add a Before Table event to your table by right clicking and selecting Events

Create a new script by clicking Script builder wizard  and choosing Load table from resource

This autogenerates a script that runs immediately before the table renders on the screen and retrieves the data from the database.

10

Run your form  and you'll see your data on the screen.

11

In the Studio, add a button to your form and label it UPDATE.

12

Add a new script to your button.

Using the Script Wizard again, select Update table

13

Run your form again.

In the table, change the name Tiddles to Tom and click UPDATE.

Reload the page, and you'll see the table display your changed data.

14

In the Studio, select Show Delete column in the Properties panel on the right.

Run the form again, select a row for deletion and click UPDATE.

Related