CreateFrom method (DataWindows)
Description
Creates a DataStore object from the passed ResultSet object.
Controls
DataWindow type |
Method applies to |
---|---|
PowerBuilder |
DataStore object |
Syntax
[PowerBuilder]
1 |
integer <span>dsobject</span>.<span>CreateFrom</span> ( ResultSet <span>rssource </span>) |
Argument |
Description |
---|---|
dsobject |
The name of the DataStore object into |
rssource |
A ResultSet or ADOResultSet object that |
Return Values
Integer. Returns 1 if it succeeds or a negative number if
an error occurs. If any argument is null, in PowerBuilder the method
returns null.
Usage
Use CreateFrom to create a DataStore from
a passed result set. Typically, a PowerBuilder client calls methods
on a component running in a transaction server and converts results
sets returned from those methods to DataStore objects using CreateFrom.
CreateFrom creates an external DataWindow
definition with no visual component—it has no controls
and the height of all bands is zero. Since the data source for the
DataStore object is external, Update methods on the DataStore object
have no effect. The Print method will print a blank page.
Client applications can use the DataStore object directly
or display the data in a DataWindow control using the ShareData
method.
For more information about result sets and methods for exchanging
data between components and clients, see Usage for GenerateResultSet.
Examples
This example creates an instance of the SVUBookstore
component, calls the GetMajors method, and creates
a DataStore object using the data definition in the returned ResultSet
object:
1 |
SVUBookstore lcst_mybookstore |
1 |
resultset lrs_resultset |
1 |
datastore ds_local |
1 |
integer li_rc |
1 |
1 |
li_rc = myconnect.CreateInstance(lcst_mybookstore) |
1 |
IF li_rc <> 0 THEN |
1 |
MessageBox("Create Instance", string(li_rc) ) |
1 |
myconnect.DisConnectServer() |
1 |
RETURN |
1 |
END IF |
1 |
1 |
lrs_resultset = lcst_mybookstore.GetMajors() |
1 |
1 |
ds_local = CREATE DataStore |
1 |
ds_local.<span>CreateFrom</span>(lrs_resultset) |
This example creates a DataStore object from an ADO
Recordset returned from a method on an MTS component.
1 |
OLEObject loo_mycomponent |
1 |
OLEObject loo_ADOrecordset |
1 |
ADOresultset lrs_ADOresultset |
1 |
datastore ds_local |
1 |
integer li_rc |
1 |
1 |
loo_mycomponent = CREATE OLEObject |
1 |
li_rc = loo_mycomponent.ConnectToNewObject("PB.Test") |
1 |
IF li_rc <> 0 THEN |
1 |
MessageBox("Connect Failed", string(li_rc) ) |
1 |
RETURN |
1 |
END IF |
1 |
1 |
// Use an OLEObject to hold ADO Recordset |
1 |
// returned from method on MTS component |
1 |
loo_ADOrecordset = loo_mycomponent.GetTestResult() |
1 |
1 |
// Create an ADOResultSet and get its data |
1 |
// from OLEObject holding passed ADO Recordset |
1 |
lrs_ADOresultset = CREATE ADOResultSet |
1 |
lrs_ADOresultset.SetRecordSet(loo_ADOrecordset) |
1 |
1 |
// Use CreateFrom to populate DataStore |
1 |
// from ADOResultSet object |
1 |
ds_local = CREATE DataStore |
1 |
ds_local.<span>CreateFrom</span>(lrs_ADOresultset) |
See Also
-
SetRecordSet in the PowerScript Reference
-
SetResultSet in the PowerScript Reference