Server  4: AdoRelationServer

<< Click to Display Table of Contents >>

Navigation:  Examples > Server >

Server  4: AdoRelationServer

Previous pageReturn to chapter overviewNext page

The sample below shows how you can use the AdoRelation Server to create a relation between two servers:

 

FUNCTION Start

 // this sample shows how to use the AdoRelationServer object

 LOCAL oConn AS AdoConnection

 LOCAL oSrv AS AdoRelationServer

 LOCAL oSrv2 AS AdoRelationServer

 LOCAL strCnn AS STRING

 LOCAL oCons AS Console

 oCons := Console{}

 strCnn := "Provider=sqloledb;" + ;

 "Data Source=(local);Initial Catalog=pubs;User Id=sa;Password=; "

 oConn := AdoConnection{}

 // Set the default connection for better error reports

 

 AdoSetConnection(oConn)

 oConn:CursorLocation := adUseClient

 oConn:Open(strCnn,NIL,NIL,NIL)

 oSrv := AdoRelationServer{"publishers",oConn,adOpenKeySet,NIL,adCmdTable}

 oSrv2 := AdoRelationServer{"Titles",oConn,adOpenKeySet,NIL,adCmdTable}

 //    oSrv2:Filter := "Title like '%us%'"

 oSrv:SetRelation(oSrv2,#Pub_id)

 // Open a recordset USING a client Side, KeySet cursor

 // FOR the employee table.

 DO WHILE ! oSrv:EOF .and. oSrv:RECNO < 5

 oCOns:WriteLine(AsString(oSrv:RECNO) + " "+ AsString(oSrv:<text style="font-family:'Courier New'; font-size:10pt; color:#000000;" translate="true">FIELDGET(1))+ " "+ ;

         AsString( oSrv:FIELDGET(2))+ " "+ AsString( oSrv:FIELDGET(3) ) + " ";

          +AsString( oSrv:FIELDGET(4)))

 oSrv2:GoTop()

 oCOns:WriteLine( "# of titles "+ AsString( oSrv2:RecCount))

 DO WHILE ! oSrv2:EOF

         oCOns:WriteLine( "* "+AsString(oSrv2:RECNO)+" "+AsString( oSrv2:FIELDGET(1))+" "+;

         AsString( oSrv2:FIELDGET(2)))

         oSrv2:Skip(1)

 ENDDO

 oSrv:Skip(1)

 oCons:Write("Press Enter")

 oCOns:Read()

 ENDDO

 oSrv:Close()

 oSrv2:Close()

 oConn:Close()