SetValue method (DataWindows)
Description
Sets the value of an item in a value list or code table for
a column in a DataWindow control or DataStore. (A value list is
called a code table when it has both display and data values.) SetValue does
not affect the data stored in the column.
SetValueByColNum
A separate method name is provided as an alternative syntax
for the Web DataWindow server component, which cannot use overloaded
methods.
Controls
|
DataWindow type |
Method applies to |
|---|---|
|
PowerBuilder |
DataWindow control, DataWindowChild object, DataStore |
|
Web |
Server component |
|
Web ActiveX |
DataWindow control |
Syntax
[PowerBuilder]
|
1 |
integer <span>dwcontrol</span>.<span>SetValue</span> ( string <span>column</span>, integer <span>index</span>, string <span>value</span> )<br>integer <span>dwcontrol</span>.<span>SetValue</span> ( integer <span>column</span>, integer <span>index</span>, string <span>value</span> ) |
[Web DataWindow server component]
|
1 |
short <span>dwcontrol</span>.<span>SetValue</span> ( string <span>column</span>, short <span>index</span>, string <span>value</span> )<br>short <span>dwcontrol</span>.<span>SetValueByColNum</span> ( short <span>column</span>, short <span>index</span>, <br> string <span>value</span> ) |
[Web ActiveX]
|
1 |
number <span>dwcontrol</span>.<span>SetValue</span> ( string <span>column</span>, number <span>index</span>, string <span>value</span>) <br>number <span>dwcontrol</span>.<span>SetValue</span> ( number <span>column</span>, number <span>index</span>, <br> string <span>value</span>) |
|
Argument |
Description |
|---|---|
|
dwcontrol |
A reference to a DataWindow control or |
|
column |
The column that contains the value list The edit style of the column can be DropDownListBox, Edit, |
|
index |
The number of the item in the value list |
|
value |
A string whose value is the new value |
Return Values
Returns 1 if it succeeds and -1 if an error occurs. If any
argument’s value is null, in PowerBuilder and JavaScript
the method returns null.
Examples
This statement sets the value of item 3 in the value
list for the column emp_state of dw_employee to
Texas:
|
1 |
dw_employee.<span>SetValue</span>("emp_state", 3, "Texas") |
This statement sets the display value of item 3 in
the code table for the column named emp_state of dw_employee
to Texas and the data value to TX:
|
1 |
dw_employee.<span>SetValue</span>("emp_state", 3, "Texas~tTX") |
The following statements use a SQL cursor
and FETCH statement to populate the ListBox portion
of a DropDownListBox style column called product_col of
a DataWindow object with code table values:
|
1 |
integer prod_code, i = 1 |
|
1 |
string prod_name |
|
1 |
|
1 |
DECLARE prodcur CURSOR FOR |
|
1 |
SELECT product.name, product.code |
|
1 |
FROM product USING SQLCA; |
|
1 |
|
1 |
CONNECT USING SQLCA; |
|
1 |
IF SQLCA.SQLCode <> 0 THEN |
|
1 |
MessageBox("Status","Connect Failed " & |
|
1 |
+ SQLCA.SQLErrText) |
|
1 |
RETURN |
|
1 |
END IF |
|
1 |
|
1 |
OPEN prodcur; |
|
1 |
IF SQLCA.SQLCode <> 0 THEN |
|
1 |
MessageBox("Status","Cursor Open Failed " & |
|
1 |
+ SQLCA.SQLErrText) |
|
1 |
RETURN |
|
1 |
END IF |
|
1 |
|
1 |
FETCH prodcur INTO :prod_name, :prod_code; |
|
1 |
|
1 |
DO WHILE SQLCA.SQLCode = 0 |
|
1 |
dw_products.<span>SetValue</span>("product_col", i, & |
|
1 |
prod_name + "~t" + String(prod_code)) |
|
1 |
i = i + 1 |
|
1 |
FETCH prodcur INTO :prod_name, :prod_code; |
|
1 |
LOOP |
|
1 |
|
1 |
CLOSE prodcur; |
|
1 |
DISCONNECT USING SQLCA; |