Hyderabad Jobs Book Website FREE PowerBuilder Training I Love Hyderabad Hyderabad Colleges
Home Business Emails Hyderabad Classifieds Contact Us
7 Wonders of Hyderabad Web Hosting Yellow Pages Our Network

 
Webpowerbuilder.hyderabad-colleges.com

Mastering PowerBuilder

HomePrevious Lesson: Creating a Custom Connection Object
Next Lesson: Building Proxy Objects

Creating the Remote Object

Select File > New menu option and double click on Custom Class icon located under Object tab page and select Connection and click OK button. This class has two methods, of_Retrieve() to retrieve products and of_Update() to save changes done to the product. These two functions act on an instance variable ids_product DataStore.
Protected:
DataStore ids_Product

Let us create the DataStore in the Constructor event and initialize it.
// Event: Constructor
// Object: ncst_product_master
// Create a DataStore
ids_product = CREATE DataStore
// Assign DataWindow object that points to the product_master table
ids_product.DataObject = 'd_products_maint'
// Set the transaction object
ids_product.SetTransObject( SQLCA )

Now let's declare the method to retrieve products from the database.
// Function: of_Retrieve
// Access: Public
// Return Value: Long
// Arguments: ablb_data of type BLOB by reference
Long ll_RowCount
ids_product.Retrieve()
ll_RowCount = ids_product.GetFullState( ablb_data )
Return ll_RowCount

In this function we are basically retrieving data using Retrieve(). Then we are calling GetFullState()introduced in v6.0, retrieves complete DataWindow/DataStore state information such as data buffers and status flags including the DataWindow object about the specified DataWindow into a BLOB object. This function is primarily used in distributed PowerBuilder applications to synchronize DataStore on the server with DataWindow/DataStore on the client side, even though you can use it in normal PowerBuilder applications. Once you have the information in a BLOB object, you can use that BLOB object to set the target DataWindow using SetFullState() function.

There are two more interesting functions GetChanges() and SetChanges()that allows you to update a DataWindow. These functions also take a BLOB variable as argument. GetChanges()populates the BLOB object with the changes information and the size is a lot smaller compared to the BLOB returned in the GetFullState(). The following is the code for the of_Update() at ncst_Product_Master.
// Function: of_Update
// Access: Public
// Returns: Long
// Arguments: ablb_changes of BLOB datatype by reference
long ll_rc 
int li_UpdateStatus
ll_rc = ids_Product.SetChanges(ablb_changes)
If ll_rc >= 0 Then
   li_UpdateStatus = ids_Product.Update()
   If li_UpdateStatus = 1 Then 
      COMMIT; 
      ll_rc = ids_Product.GetChanges(ablb_changes) 
   Else 
      ROLLBACK; 
   End If 
End If 
return ll_rc

In the above function first we are applying the changes to the DataStore and then updating the DataStore. Later we are getting the changes into the BLOB variable which is used in the SetChanges()at the client side.
HomePrevious Lesson: Creating a Custom Connection Object
Next Lesson: Building Proxy Objects

Copyright © 1996 - 2006 HamaraShehar.com Pvt. Ltd. All Rights Reserved.
Domain Registration, Website Design, Website Hosting by HamaraShehar.com