Command 1: Simple Command

<< Click to Display Table of Contents >>

Navigation:  Examples > Command >

Command 1: Simple Command

Previous pageReturn to chapter overviewNext page

The following sample shows how to execute SQL statements using the AdoCommand class:

 

FUNCTION Start

 LOCAL oConn        AS AdoConnection

 LOCAL cbErr        AS CODEBLOCK

 LOCAL uError        AS USUAL

 LOCAL oCmd        AS AdoCommand

 LOCAL lResult        AS USUAL

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

 BEGIN SEQUENCE

   oConn := OpenConnection()

   oCmd := AdoCommand{}

   oCmd:ActiveConnection := oConn

   oCmd:CommandText := "Update titles set advance = advance + 1"

  ? "Using Command OBJEct to execute Update statement"

  ? "Executing CODE: "+oCmd:CommandText

   oCmd:Execute(@lResult,NIL,NIL)

  ? "You have updated", lResult , "rows"

 

 RECOVER USING uError

  ? "Error: "+uError:description

 END

 wait

 

 RETURN