| Home | Previous Lesson: Where To Use a DataStore? Next Lesson: How Is DataStore Object Different From DataWindow Control ? |
As you know, we are using a hidden DataWindow control, dw_product_check in the w_product_master window. What for we are using this hidden DataWindow control? We want to check whether the new product the user entered is existing in the database or not. If isn't existing, we are displaying an error.
Let's use the DataStore to get the same functionality that we are getting by hidden DataWindow control.
Declare an instance variable as follows:
DataStore ids_ProductCheck
Append the following to the existing script for the window open event:
ids_ProductCheck = CREATE DATASTORE
ids_ProductCheck.DataObject = "d_display_product"
ids_ProductCheck.SetTransObject( SQLCA )
We are creating an instance of a DataStore object and assigning the DataWindow object to the DataStore object, similar to the way we change the DataWindow object to a DataWindow control. Then we are setting the transaction object.
Comment the following script that is related to the hidden DataWindow control.
// dw_product_check.SetTransObject( SQLCA )
Comment the following line in the ItemChanged event of dw_product DataWindow control:
//dw_product_check.Retrieve( Integer( Data ) )
Add the following line just below the above line:
ids_ProductCheck.Retrieve( Integer( Data ) )
Similarly, comment the following line:
// If dw_product_check.RowCount() = 1 Then
Add the following line just below the above line:
If ids_ProductCheck.RowCount() = 1 Then
A good programmer destroy all the object that (s)he has created. So, let's do the same. Add the following line in the window Close event:
DESTROY ids_ProductCheck
Now, run the application and see whether it's working properly or not.
| Home | Previous Lesson: Where To Use a DataStore? Next Lesson: How Is DataStore Object Different From DataWindow Control ? |