CreateFrom

Description

Creates a DataStore object from the passed ResultSet object.

Applies to

DataWindow type

Method applies to

PowerBuilder

DataStore object

Syntax

PowerBuilder

integer dsobject.CreateFrom ( ResultSet rssource )

Argument

Description

dsobject

The name of the DataStore object into which you want to place the data in the passed result set

rssource

A ResultSet or ADOResultSet object that contains meta data from which the DataStore object is created

Returns

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

Example 1

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:

SVUBookstore lcst_mybookstore

resultset lrs_resultset

datastore ds_local

integer li_rc


li_rc = myconnect.CreateInstance(lcst_mybookstore)

IF li_rc <> 0 THEN

		MessageBox("Create Instance", string(li_rc) )

		myconnect.DisConnectServer()

		RETURN

END IF


lrs_resultset = lcst_mybookstore.GetMajors()


ds_local = CREATE DataStore

ds_local.CreateFrom(lrs_resultset)

Example 2

This example creates a DataStore object from an ADO Recordset returned from a method on an MTS component.

OLEObject loo_mycomponent

OLEObject loo_ADOrecordset

ADOresultset lrs_ADOresultset

datastore ds_local

integer li_rc


loo_mycomponent = CREATE OLEObject

li_rc = loo_mycomponent.ConnectToNewObject("PB.Test")

IF li_rc <> 0 THEN

		MessageBox("Connect Failed", string(li_rc) )

		RETURN

END IF


// Use an OLEObject to hold ADO Recordset

// returned from method on MTS component

loo_ADOrecordset = loo_mycomponent.GetTestResult()


// Create an ADOResultSet and get its data

// from OLEObject holding passed ADO Recordset

lrs_ADOresultset = CREATE ADOResultSet

lrs_ADOresultset.SetRecordSet(loo_ADOrecordset)


// Use CreateFrom to populate DataStore 

// from ADOResultSet object

ds_local = CREATE DataStore

ds_local.CreateFrom(lrs_ADOresultset)

See also