" *****************************************************************************************************
*
This examples shows how to open a connection and use driver connect to
   connect to a Data Source
*
******************************************************************************************************"

|connection1  aTextDisplay connectString |

aTextDisplay := TextWindow  windowLabeled: 'ODBC Interface - Using Driver Connect '
                           frame: (0 @ 0 corner: 1000 @ 1000).
aTextDisplay cr.



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

connection1 := OdbcConnection open.
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
    ].



aTextDisplay cr
                     ; nextPutAll: 'Output from call to SQLDriverConnect:'
                    ;nextPutAll: connectString;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 ***'.
