Generates a result set from data in a DataStore or DataWindow control.

In PowerBuilder, when the result set is generated in a component on a transaction server, the format of the result set is ADO Recordset on MTS.

Applies to

DataWindow type

Method applies to


DataStore object



integer dsobject.GenerateResultSet (REF ResultSet rsdest { ,dwBuffer dwbuffer } )




The name of the DataStore object that contains the data to be returned in the result set.


The ResultSet object into which the data in the DataStore is written. This value is passed by reference.

dwbuffer (optional)

A value of the dwBuffer enumerated datatype identifying the DataWindow buffer containing the data for the result set. The default is the primary buffer.

For a list of valid values, see DWBuffer.

Return value

Returns 1 if it succeeds and -1 if it fails. If any argument is null, it returns null.


How to use it

Result sets are intended for exchanging data between a DataStore and some data-aware application that does not use DataWindow technology. With result sets, the receiving end does not support updating of the data.

The GenerateResultSet method is typically used in a PowerBuilder custom class user object that has been packaged as a component on an MTS server. A function in the user object generates a result set from information that has been retrieved into a DataStore. The function then returns the result set or passes it to another method.

For example, a function for PowerBuilder custom class user object running in a transaction server can retrieve data into a DataStore object, create a result set object, and return the result set. A client application calls the function to get the data. The client application must be able to handle result sets, but it does not need to have support for DataWindow technology.

Likewise, a client application can generate a result set from a DataStore and pass the result set to the server.

The CreateFrom method can convert a result set back to a DataStore.

Result set format

The result set is returned to a client in a format that is standard for the server. In MTS, returning a result set created by GenerateResultSet causes an ADO Recordset to be marshaled to the client.

The GenerateResultSet method can also be called in a client application. Since the format of the result set depends on the server on which it is used, the format is fixed when that result set is passed to a server. For MTS, the format is an ADO Recordset.

Destroying or modifying the DataStore

The generated ResultSet object maintains a reference to the DataStore from which it was generated, so changes made to the DataStore object after the result set is generated will be reflected in the generated ResultSet object. If you destroy the DataStore object before returning the result set, the result set becomes invalid. You can rely on garbage collection to destroy the DataStore object or destroy it explicitly in the component's deactivate event.


In this example, a DataStore object is created and data is retrieved into it, and then the GenerateResultSet method is used to create a result set that can be returned to a client.

datastore ds_datastore
resultset lrs_resultset
integer li_rc
ds_datastore = CREATE DataStore
ds_datastore.SetTransObject (SQLCA)
IF ds_datastore.Retrieve() = -1 THEN
      ... // report error and return
li_rc = ds_datastore.GenerateResultSet(lrs_resultset)
IF li_rc <> 1 THEN
      ... // report error and return
return lrs_resultset

See also


SetRecordSet in the section called “SetRecordSet” in PowerScript Reference