Intercepting error messages from SQL Server?
Quote:
>I am writing a client server program using VFP with SQL Server. I would
>like to intercept and interpret SQL Server error messages. Currently I
>use the AERROR() function in VFP. Whenever I get an error resulting from
>syntax error, foreign key violation, or duplicate primary key I only see
>error #1526. I would rather see the specific SQL errors (ie. 547 for
>constraint failure). Any ideas on how I might be able to accomplish
>this? Thanks.
Since I found an answer I thought I'd pass it along. The answer does lie in
AERROR() but it is not obvious. Check out the knowledge base article Q130506
titled Use AERROR() in place of DBERROR() for ODBC errors. AERROR() returns
an array of information. Elements (1,3) and (1,5) return the SQL Server error
message and number. I hope this is useful for those developing SQL Server
apps.