Using a custom DataStore object – PB Docs 126

Using a custom DataStore object

This section describes how to extend a DataStore in PowerBuilder
by creating a user object.

You might want to use a custom version of the DataStore object
that performs specialized processing. To define a custom DataStore,
you use the User Object painter. There you specify the DataWindow
object for the DataStore, and you can optionally write scripts for
events or define your own methods, user events, and instance variables.

Using a custom DataStore involves two procedures:

  1. In the User Object
    painter, define and save a standard class user object inherited
    from the built-in DataStore object.

  2. Use the custom DataStore in your PowerBuilder application.

Once you have defined a custom DataStore in the User Object
painter, you can write code that uses the user object to perform
the processing you want.

For instructions on using the User Object
painter in PowerBuilder, see the PowerBuilder Users Guide.

proc.png To define the standard class user object:

  1. Select Standard Class User Object on the
    PBObjects tab in the New dialog box.

  2. Select datastore as the built-in system type that
    you want your user object to inherit from, and click OK.

    The User Object painter workspace displays so that you can
    define the custom object.

  3. Specify the name of the DataWindow object in the
    DataObject box in the Properties view and click OK.

  4. Customize the DataStore by scripting the events
    for the object, or by defining methods, user events, and instance

  5. Save the object.

proc.png To use the user object in your application:

  1. Select the object or control for which
    you want to write a script.

  2. Open the Script view and select the event for
    which you want to write the script.

  3. Write code that uses the user object to do the
    necessary processing.

    Here is a simple code example that shows how to use a custom
    DataStore to retrieve data from the database. First it instantiates
    the custom DataStore object, then it sets the transaction object
    and retrieves data into the DataStore:

    Notice that this script does not assign the DataWindow object
    to the DataStore. This is because the DataWindow object is specified
    in the user object definition.

    note.png Changing the DataWindow object at execution time

    When you associate a DataWindow object with a DataStore in
    the User Object painter, you are setting the initial value of the
    DataStore’s DataObject property. During execution, you
    can change the DataWindow object for the DataStore by changing the
    value of the DataObject property.

  4. Compile the script and save your changes.

Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x