David,
Check the value in the err variable from this statement:
set err [odbc SQLConnect $hdbc $dsn SQL_NTS $usr SQL_NTS $pwd SQL_NTS]
If the value is SQL_ERR then there was a problem connecting.
You can get the details of the error by executing SQLGetDiagRec (look up the syntax on the Microsoft site).
What we do if the connection is rejected is to sleep for a period of time for x number of periods. If we still have an error then we take error handling action (send email/pages, stop threads, etc.)
One thing though the thread where the ODBC activity is occuring should be in its own process so the sleep and other timing issues with ODBC do not interfere with other work in the site (including the arrival of new messages).
email: jim.kosloskey@jim-kosloskey.com 30+ years Cloverleaf, 60 years IT – old fart.