" *****************************************************************************************************
*
* sconnopt.txt
*
*   This examples shows how to use setConnectOption.
*
*   Note: The option ODBCCURSORS must be set before the application is connected to the
*             data source.
*
******************************************************************************************************"

|connection1  aTextDisplay connectString |

aTextDisplay := TextWindow  windowLabeled: 'ODBC Interface - Using getConnectOption'
                           frame: (0 @ 0 corner: 500 @ 500).
aTextDisplay cr.



" *** Open the connection ****"

connection1 := OdbcConnection open.
connection1 hasError
    ifTrue:
    [    aTextDisplay nextPutAll: connection1 getMessage; cr
    ].

 
" force the connection to use the driver cursor library"                     
connection1 setOption: (OdbcConnectOptions at: 'ODBCCURSORS')  value: 1 .
connection1 hasError
    ifTrue:
    [    aTextDisplay nextPutAll: connection1 getMessage; cr
    ].


" *** Driver  Connect ***
 Valid Driver completions code are in OdbcDriverCompletions "

connectString :=  connection1 driverConnect: '' window: aTextDisplay
        driverCompletion: (OdbcDriverCompletions at: 'DRIVERPROMPT').

connection1 hasError
    ifTrue:
    [    aTextDisplay nextPutAll: connection1 getMessage; cr
    ].




" *** display the connect options and their values ***"
 
   OdbcConnectOptions  associationsDo:
     [ :a|
         aTextDisplay nextPutAll: (a key) ; tab
                              ; nextPutAll:  (connection1 getOption:  a value) asString ; cr.
    ].



" *** disconnect *** "
connection1 disconnect.
connection1 hasError
    ifTrue:
    [    aTextDisplay nextPutAll: connection1 getMessage; cr
    ].


" *** free the connection *** "

connection1 free.
connection1 hasError
    ifTrue:
    [    aTextDisplay nextPutAll: connection1 getMessage; cr
    ].


aTextDisplay nextPutAll: '*** finished executing ***'.
