If this is your first visit to our forums, welcome!
Maybe SQLGetMessage? Haven't tested it, but looks to be, what you are looking for.
Forum Rules