In this example, we use a function to load a table of our database to DropDownListBox Power Builder.
For our example we will use the NorthWind database
Before starting with our example, we spend a few concepts:
SetRedraw:
Controls automatic redrawing of an object or control after each change in its properties.
Return Value: Integer. Returns 1 if successful and -1 if an error occurs. Boolean If NULL, returns null SetRedraw.
Syntax:
objectname.SetRedraw (boolean)
Reset:
Removes all elements from a list. Can be used with the ListBox, DropDownListBox, PictureListBox, and DropDownPictureListBox.
Return Value: Integer. Returns 1 if successful and -1 if an error occurs. If control is null, the Reset returns null. The return value is not used.
Syntax:
objectname.Reset ()
Let us design our form:

We declare our variables intance Variable type: string
ls_select_string, ls_add_string
Now let's create our function with the name of f_llenar_ddlb :

Then script for the function:
ls_select_string = "SELECT DISTINCT "+ columna_param +" FROM "+ tabla_param +" "+ where_param
sqlsa PREPARE FROM: ls_select_string;
dyn_cursor DYNAMIC DECLARE CURSOR FOR sqlsa;
OPEN DYNAMIC
dyn_cursor;
SQLCA.SQLCODE
< 0 then
if MessageBox (" Error Base data! "sqlca.sqlerrtext)
SQLCA.SQLCODE
return end if
ddlb_param.SetRedraw (false)
ddlb_param.Reset () Do While
SQLCA.SQLCODE = 0
Fetch dyn_cursor into: ls_add_string;
if sqlca . sqlcode = 0 then
ddlb_param.AddItem (ls_add_string) elseif
SQLCA.SQLCODE < 0 then
MessageBox ("Database Error", sqlca.sqlerrtext) Else return SQLCA.SQLCODE
exit end if Loop
ddlb_param.SetRedraw (true)
Close dyn_cursor;
return 0
now to view our data in the table, we call our function that we created, and we must write our script in the event the windows open:
f_llenar_ddlb ('categories', 'categoryName' ddlb_categoria,'')
compiled and run the windows:
