Introduction to PowerBuilder Saving Changes to the
Database
// Object: cb_save in window w_product_master
// Event: Clicked
int lUserAnswer, lUpdateStatus
lUserAnswer = MessageBox( "Update", &
"Apply Changes ?", Question!,YesNo!,2)
if lUserAnswer = 1 then
SetPointer( HourGlass! )
lUpdateStatus = dw_product.Update()
if lUpdateStatus = 1 then
commit using SQLCA;
else
SetPointer( Arrow! )
RollBack using SQLCA;
MessageBox( "Update", "Error in update" + &
"Error Message: " + SQLCA.SqlErrText )
return 0
end if
end if
SetPointer( Arrow! )
The first thing we did was get a
confirmation from the user regarding applying changes to the data. If the reply is
positive, we call the Update() function and commit the changes, otherwise we ROLLBACK. While saving information to the database, it is a good idea to change the mouse
pointer to an HourGlass, to indicate about the on going operation.
You should always keep the user informed
about the things going on in an application. If a lengthy operation is in progress, you
should give them an indication of it, otherwise, the user might think that things have
gone wrong. The following table illustrates some of the general guidelines for lengthy
operations:
Duration |
Action |
<= 4
seconds |
Optional
HourGlass cursor. |
5 - 15
seconds |
Display
the HourGlass cursor. |
15+
seconds |
Display
a message box and preferably an indicator for the progress. |
|