The following are a few code examples showing how to call the .NET DataStore Service APIs from PowerScript.
For more examples, refer to RetrieveWithModel, UpdateWithModel, and RetrieveOrUpdateWithModels.
Example 1: To retrieve data for only one DataWindow
long ll_return
RestClient lnv_RestClient
lnv_RestClient = Create RestClient
// Retrieve data via .NET DataStore Service
ll_return = lnv_RestClient.RetrieveWithModel(dw_emp, "http://localhost:5099/RetrieveWithModel", 102)
//// Update data via .NET DataStore Service
// ll_return = lnv_RestClient.UpdateWithModel(dw_emp, "http://localhost:5099/UpdateWithModel")
// Check the return value
if ll_return >= 0 then
MessageBox("Success", "Rows = " + String(ll_return))
else
MessageBox("Error", "Failed to retrieve data.")
end ifExample 2: To retrieve data for more than one DataWindow
Integer li_return, li_index
RestClient lnv_RestClient
BatchDataObjects lnv_objects
lnv_RestClient = Create RestClient
lnv_objects.AddUpdateObject(dw_dept)
lnv_objects.AddUpdateObject(dw_emp)
lnv_objects.AddRetrieveObject(dw_emp, 129)
if lnv_objects.GetCount() <= 0 then
MessageBox("Error", "Error when add dwControl to BatchDataObjects")
return
end if
// Send request to .NET DataStore Service
li_return = lnv_RestClient.RetrieveOrUpdateWithModels (lnv_objects ,"http://localhost:5099/RetrieveOrUpdateWithModels")
// Check the return value
if li_return = 1 then
MessageBox("Success", "Return = " + String(li_return))
else
li_index = lnv_objects.GetErrorIndex()
if li_index > 0 then
MessageBox("RetrieveOrUpdateWithModels Error(Index:" + String(li_index) + ")", &
"Error DB Code:"+ string(lnv_objects.GetSQLDBCode()) + "\r\n Error Message:" + lnv_objects.GetSQLErrText())
else
//handle other error
end if
end if


