Description
Suppose the client has a window called w_employee that has buttons that allow the user to retrieve and update data.
Client window definition
The Retrieve button on the client window has the following script:
// Global variable: // connection myconnect // Instance variable: // uo_employee iuo_employee
blob lblb_data long ll_rv
myconnect.CreateInstance(iuo_employee) iuo_employee.RetrieveData(lblb_data)
ll_rv = dw_employee.SetFullState(lblb_data)
if ll_rv = -1 then MessageBox("Error", "SetFullState call failed!") end if
The Update button on the client window has the following script:
blob lblb_changes long ll_rv
ll_rv = dw_employee.GetChanges(lblb_changes)
if ll_rv = -1 then MessageBox("Error", "GetChanges call failed!") end if if iuo_employee.UpdateData(lblb_changes) = 0 then dw_employee.SetChanges(lblb_changes) end if
Server object definition
The server has an object called uo_employee that has the following functions:
Constructor
The Constructor event for the uo_employee object creates the DataStore that will be used to access the database:
ids_datastore = create datastore ids_datastore.dataobject = "d_emplist" ids_datastore.SetTransObject (SQLCA)
Script for the RetrieveData function
The RetrieveData function takes an argument called ablb_data, which is passed by reference. The function returns a long value.
Here is the script for the RetrieveData function:
// Instance variable: // datastore ids_datastore
long ll_rv
ids_datastore.Retrieve()
ll_rv = ids_datastore.GetFullState(ablb_data)
return ll_rv
Script for the UpdateData function
The UpdateData function takes an argument called ablb_changes, which is passed by reference. The function returns a long value.
Here is the script for the UpdateData function:
// Instance variable: // datastore ids_datastore
long ll_rv
if ids_datastore.SetChanges(ablb_data) = 1 then ll_rv = ids_datastore.Update() end if if ll_rv = 1 then COMMIT ids_datastore.GetChanges(ablb_data) else ROLLBACK end if return ll_rv
|