Microsoft KB Archive/134721

= HOWTO: How to Handle Visual FoxPro Connectivity Errors w/o DBERROR =

Article ID: 134721

Article Last Modified on 2/22/2005

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Data Access Components 2.5

-



This article was previously published under Q134721



SUMMARY
The DBERROR function from previous versions no longer exists nor does an equivalent SQLERROR function that you might expect to find. There are still ways to find out the same information though. The function AERROR is used throughout the product for retrieving error information and the SQLSETPROP function also gives us some control over the SQL error messages specifically.



First Method
Using Aerror will create an array containing the error code and error message. It could be implemented as follows for catching the full ODBC error that occurs when connecting to a datasource : **************************** dsource='test' Handle=SQLCONNECT(dsource,"","") IF HANDLE<0 retval=AERROR(atmp) errval=atmp(1,1) errmsg=atmp(1,2) WAIT WINDOW STR(ERRVAL)+": "+ERRMSG ENDIF
 * Example of using AERROR

Second Method
Setting up similar error trapping would be to use the SQLSetProp function to set the DispWarning property to True. This will actually be easier than the old DBError function because once this is set the full ODBC error text will automatically be displayed without having to test the return value or having to fill variables and display them yourself. A connection handle of 0 sets this as a default for all subsequent connections. **************************** retval=SQLSETPROP(0,"DispWarnings",.T.) dsource='test' Handle=SQLCONNECT(dsource,"","") && Error returning line
 * Example using SQLSETPROP
 * The "0" parameter above creates a "dummy" channel to turn Dispwarnings on

Additional query words: VFoxWin ck

Keywords: kbhowto KB134721

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.