Vo2Ado Server Editors example

<< Click to Display Table of Contents >>

Navigation:  Examples >

Vo2Ado Server Editors example

Previous pageReturn to chapter overviewNext page

This sample shows you the result of using the Vo2Ado Server Editor.

The following modules contain generated code:

Pubs Connection:        A connection class

Authors Server:        A server class that uses the Pubs Connection

Authors Window:        A Datawindow class that uses the Author Server

FieldSpecs:            A module with all the generated fieldspecs

 

All the sourcecode that was generated from the Server and Connection Editors was 'template driven'. See the Server Editors help file for more details about these templates

 

The Pubs connection entity looks like this in the editor

 

PubsConn

and the generated sourcecode looks like this:

 

CLASS Pubs INHERIT AdoConnection

 

METHOD INIT() CLASS Pubs

LOCAL cbErr AS CodeBlock

LOCAL nTimeOut as USUAL

cbErr := ErrorBlock({|oErr|_Break(oErr)})

BEGIN SEQUENCE

  SUPER:Init()

  SELF:ConnectionString := "Provider=Microsoft.Jet.OLEDB.4.0;" + ;

 "Data Source=C:\Vo2Ado26\northwind.mdb;"        

  SELF:CursorLocation   := adUseServer

  nTimeOut := 0

  IF ! IsNil(nTimeOut)

    SELF:ConnectiontimeOut       := nTimeOut

  ENDIF

  Self:Properties:[Item,"prompt"]:Value := AdPromptCompleteRequired

  SELF:Open(NIL, "Admin", NIL,NIL)

  if FALSE

      AdoSetConnection(Self)

  endif

END

ErrorBlock(cbErr)

RETURN SELF

 

The Authors Server entity looks like this:

 

AuthorsServer

 

And the generated sourcecode looks like this (Note: there are no accesses and assigns, because the "No Accesses/Assigns" checkbox has been checked. Also the fieldspecs have generic names because "Use Generic Fieldspecs" has been checked.

 

CLASS authors INHERIT AdoServer

//{{%UC%}} USER CODE STARTS HERE (do NOT remove this line)

 

ACCESS FieldDesc CLASS authors

  //

  //  This section is modelled after the DbServer Editor Template

  //

  LOCAL aRet     AS ARRAY

  LOCAL nFields   AS INT

 

   nFields := 9

 

  IF nFields > 0

       aRet := ArrayCreate(nFields)

       aRet[1]        := {#au_id, 'au_id', FsChar11{} }

       aRet[2]        := {#au_lname, 'au_lname', FsChar40{} }

       aRet[3]        := {#au_fname, 'au_fname', FsChar20{} }

       aRet[4]        := {#phone, 'phone', FsChar12{} }

       aRet[5]        := {#address, 'address', FsChar40{} }

       aRet[6]        := {#city, 'city', FsChar20{} }

       aRet[7]        := {#state, 'state', FsChar2{} }

       aRet[8]        := {#zip, 'zip', FsChar5{} }

       aRet[9]        := {#contract, 'contract', FsLogic{} }

 

  ELSE

       aRet := {}

  ENDIF

 

 

  RETURN aRet

 

METHOD INIT(sSource, uConn, nCursorType, nLockType, nOptions ) CLASS authors

  LOCAL i,nFields   AS INT

  LOCAL aFieldDesc   AS ARRAY

  LOCAL nPos         AS INT

  LOCAL nMaxRecords AS LONG    

  LOCAL sRecnoColumn AS STRING

  LOCAL lLongFldNam AS LOGIC

  LOCAL sStatement   AS STRING

  //

  // Elements of SQL statement

  // TableName     : authors

  // ColumnList    :

  // WhereClause   :

  // OrderByClause :

  //

 

  IF IsNil(sSource)

      // Build Select statement

       sStatement := "Select * from authors"

       sSource   := sStatement

  ENDIF

   lLongFldNam := TRUE

   nMaxRecords := 0

   sRecnoColumn := ""

   

  IF IsNil(nCursorType)

 nCursorType := adOpenStatic

  ENDIF

  IF IsNil(nLockType)

 nLockType := adLockOptimistic

  ENDIF

  IF IsNil(uConn)

       uConn := AdoGetConnection()

      // The connection in the AdoServer Editor was; Pubs

  ENDIF

 

  SELF:PreInit()

 

  SUPER:INIT(sSource, uConn, nCursorType, nLockType, nOptions, lLongFldNam)

 

   oHyperLabel := HyperLabel{#authors, "authors", "authors", NULL_STRING}

 

  IF oHLStatus = NIL

       nFields := ALen(aFieldDesc := SELF:FieldDesc)

      FOR i:=1 UPTO nFields

           nPos := SELF:FieldPos( aFieldDesc[i][DBC_NAME] )

 

          SELF:SetDataField( nPos,;

               DataField{aFieldDesc[i][DBC_SYMBOL],aFieldDesc[i][DBC_FIELDSPEC]} )

 

      NEXT

 

      SELF:GoTop()

  ENDIF

 

  SELF:PostInit()

 

  RETURN SELF

 

The Fieldspecs have all been generated in the Fieldspecs module and have a standardized name. The source code looks like this:

 

CLASS FsChar11 INHERIT FieldSpec

 

METHOD INIT() CLASS FsChar11

  LOCAL cPict        AS STRING

  SUPER:INIT(#FsChar11, &quot;C", 11, 0)

   cPict := ""

  IF sLen(cPict) > </text>0

 SELF:Picture := cPict

  ENDIF

  RETURN SELF

 

 

 

The Authors window has been totally generated using the Window editor. Autolayout was used to build the window, based on the Autors Server class