Create a data window using the PB dynamic

zhaozj2021-02-17  60

Create a data window using the PB dynamic

When using the PowerBuilder to establish a data window, the user usually does not select the data source and the display type. How to let users define their data source and display types in the application? To achieve this, we must dynamically create a data window according to the user's own needs during the operational program. The author will combine the actual and detail the steps to dynamically create a data window. Before establishing a dynamic data window, you must first get the syntax of the data window object, which provides us with the syntaxfromsql () function, using this function to get the syntax of the creation of the data window. The basic format of the syntaxfromsql () function is as follows: Event object. Syntaxfromsql (data source string, display type string, error string) Below is an example of establishing a data window object syntax: // Declared variable string ls_sql, ls_present, ls_err, LS_SYNTAX / / Data Source Ls_SQL = "SELECT EMP_ID FROM EMPLOYEE" // Defines Data Window Display String Ls_Present = "Style (Type = Tabular) // Get Creating Data Window Object Syntax // If error occurs, SyntaxFromsql Returns an empty string ls_errls_syntax = sqlca.synTaxFromsql (Ls_SQL, LS_PRESENT, LS_ERR) Using SyntaxFromsql () The data window object established by SyntaxFromsql () is an object established in the running phase and does not automatically save in the object database library of PB. In order to reuse this data window object later, you can save the data window object using the libraryImport () function. After establishing a data window syntax using the syntaxfromsql () function, it is necessary to combine it with the data window control on the window, which must already exist in the window. To combine data window object syntax and an existing data window control, you must use the create () function, the following is the sample program: // Declared variable string ls_syntax, ls_err ls_errdw_1.create (ls_syntax, ls_err) dw_1.settransobject (sqlca) DW_1.Retrieve () In the above program, LS_SYNTAX is the string returned after running the SyntaxFromsql () function. In addition, the libraryExport () function can be utilized from the PB object database to obtain data window objects that already exist in the PBL in the PB object database. Because the Create () function destroys the combination of the previous data window and the object object, you must use the setRansObject () function to restart the object object to the new data window object, and finally run the RETRIEVE () function, read data from the database. Finally, we need to use the SQL statement string to dynamically create a new data window object into a data window control. Although, a data window control can be created directly on the window, but can create a data window control as the window using the user object, and then dynamically open this user object during the run phase. Below is the step of dynamically establishing a data window control: 1. In the user object drawing, the user class of a standard data window is created. 2. After you can add functions, programs, user object functions, and user-defined events in this control, save the user object to the object database.

转载请注明原文地址:https://www.9cbs.com/read-31073.html

New Post(0)