Show/Hide Toolbars

Xs2Ado Help

Navigation: Examples > Server

Server 6: Shaped Resultsets

Scroll Prev Top Next More

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
CONSTRUCTOR()
   // 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( "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)
END CLASS