| ||
English | Slovak |
Menu: | |||||||||
|
Components of Px Framework: Program inserting of a new row into the database by means of the PxWebQuery componentTo insert new rows with the help of the PxWebQuery component you need to create a sequence, from which the PxWebQuery component shall load a unique ID for its primary key. The name of the sequence shall be created in the following way. SEQ_"name of primary key column name" Therefore, when you create new tables, do not name the primary key column as 'ID' only, but as ID + "table name". In our example, for the data inserting into the database to work as well, create the sequence by the SQL command:
CREATE SEQUENCE SEQ_IDADRESAR
Attention !!! Of course on other database platforms the sequence is created in a different way, for more details please refer to the Part Four of "Specification of using the Px Framework on different database platforms (Oracle, MS SQL, MySQL, Firebird, InterBase). Therefore, when you enter the "wquAdresar.Insert ()" command, the PxWebQuery component automatically calls the sequence, which generates a new ID for the primary key . You do not have to worry about generation and assigning of a unique key to the field where the primary key ID is entered. For more information, please refer to the example below:
wquAdresar.Insert();
Program editing of the existing row in the database by means of the PxWebQuery componentYou can edit and modify the existing row just like in the previous example, just replace the Insert command by the Edit command.
wquAdresar. Edit();
If you know the ID of the row, which you want to edit, you can find it in the following way:
if (wquAdresar.FindByIdPK(6)!=-1)
In our case, the number 6 is the column ID of the primary key row, which you are looking for and the search result (i.e. value of the column "name") is saved in the Label component. Program deleting of the existing row in the database by means of the PxWebQuery componentDeleting of the existing row can be carried out via the Delete command of the PxWebQuery component. The FindByIdPK command enables you to find the row you want to delete, then use the Delete command to delete it.
if (wquAdresar.FindByIdPK(6)!=-1)
Here is a functional example of the PxWebQuery component, even with source code. This functional example on this site runs on MySQL 5.0 database.
Others articles of Px Framework:
It doesn't the intention of this part website, describe in detail the work with PxFramework components, a detailed description of the component available in manual, which can be downloaded here: Download manual of Px Framework |