Server 6: Shaped Resultsets

<< Click to Display Table of Contents >>

Navigation:  Examples > Server >

Server 6: Shaped Resultsets

Previous pageReturn to chapter overviewNext page

This sample shows the same data as the Relation window, but uses a different approach, using the MsDataShape provider and the AdoShapeServer classes. In this case the SetRelation will take the name of the column that contains the child recordset

 

GLOBAL goConn AS AdoConnection

 

CLASS PubServer INHERIT AdoShapeServer

 EXPORT oTitles AS AdoShapeServer

METHOD Init() CLASS PubServer

 // Create a connection with the MsDataShape provider to the Pubs database

 IF goCOnn == NULL_OBJECT

         goConn   := AdoConnection{}

         goConn:Provider := "MSDataShape"

         goConn:Open ( "Data Provider=SQLOLEDB;" + ;

                 "Server=(local);uid=sa;pwd=;database=pubs",NIL,NIL,NIL)

         // Set the, so Xs2Ado can use the connection to get information

         // about the last errors that occurred

         AdoSetConnection(goConn)

 ENDIF

 // Create a shaped recordset

 SUPER:init ( "SHAPE  {select * from publishers} APPEND " + ;

         " ({select * from titles } " + ;

         " RELATE pub_id TO pub_id) AS chapTitles", ;

         goConn,adOpenStatic,adLockReadonly,NIL)

 SELF:oTitles := SELF:SetRelation(#chapTitles)