Handling odbc errors at runtime

Hi to all!
My Asterisk application connects to a MS SQL server through an odbc conector and it’s working fine. But I need to know how could I handle any odbc error that could occurs at runtime? (I.e network communication errors).
Thanks in avance.