Building SQL Server Applications
ODBC and SQL Server
Programming ODBC SQL Server Applications
Handling Errors and Messages
Diagnostic Records and Fields
The topic has a code fragment if you click on the ODBC icon under To process
ODBC errors at the bottom of the topic.
--
Thanks,
Alan Brewer
Microsoft SQL Server
Documentation Lead