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

|connection1  aTextDisplay  connectString|

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

 

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

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


 
" *** browse Connect ***"
connectString := connection1 browseConnect: 'DSN=WSQL 4.0 Sample'.
connection1 hasError
    ifTrue:
    [    aTextDisplay nextPutAll: connection1 getMessage; cr
    ].

          
" would need to parse the string , display allowable values, get input from user
  and call browse connect again until success ... then one is connected ... "

aTextDisplay cr
                     ; nextPutAll: 'Output from 1st call to SQLBrowseConnect:'
                    ;nextPutAll: connectString;cr.
                                     

                                    

" *** free the connection *** "

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


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