Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 130506 - Last Review: February 22, 2005 - Revision: 1.3
HOWTO: Use AERROR() in Place of DBERROR() for ODBC Errors
This article was previously published under Q130506
DBERROR() is no longer used to retrieve errors generated by an ODBC
function.
AERROR() is a general Visual FoxPro error function that creates a memory
variable array containing information about the most recent Visual FoxPro,
OLE, or ODBC error.
The following example shows how to use AERROR(). Here a database is
specified in the ODBC function SQLEXEC() that does not exist on the server.
nHandle=SQLCONNECT('<SQL Server data source>','sa','')
nSuccess=SQLEXEC(nHandle,'use bad_db')
Dimension aErrArray[1]
nNumerrors=AERROR(aErrArray)
The variable nNumerrors now contains the number of rows in the array
aErrArray (2 in this case) and the array aErrArray contains the error
information, as shown below:
AERRARRAY Pub A
(1,1) N 1526 ( 1526.00000000)
(1,2) C "Connectivity error: [Microsoft][ODBC SQL Server
Driver][SQL Server] Attempt to locate entry in
Sysdatabases for database 'bad_db' by name
failed - no entry found under that name. Make
sure that name is entered properly."
(1,3) C "[Microsoft][ODBC SQL Server Driver][SQL Server]
Attempt to locate entry in Sysdatabases for
database 'bad_db' by name failed - no entry
found under that name. Make sure that name is
entered properly."
(1,4) C "08004"
(1,5) N 911 ( 911.00000000)
(1,6) N 1 ( 1.00000000)
(1,7) C .NULL.
(2,1) N 1526 ( 1526.00000000)
(2,2) C "Connectivity error: [Microsoft][ODBC SQL Server
Driver][SQL Server] Attempt to locate entry in
Sysdatabases for database 'bad_db' by name
failed - no entry found under that name. Make
sure that name is entered properly."
(2,3) C "[Microsoft][ODBC SQL Server Driver][SQL Server]
Changed database context to 'pubs'."
(2,4) C "01000"
(2,5) N 5701 ( 5701.00000000)
(2,6) N 1 ( 1.00000000)
(2,7) C .NULL.
The following table describes the contents of each element when an ODBC
error numbered 1526 occurs. The array contains two or more rows; one row
for each ODBC error.
Element number Description
1 Numeric. Contains 1526.
2 Character. The text of the error message.
3 Character. The text of the ODBC error message.
4 Character. The current ODBC SQL state.
5 Numeric. The error number from the ODBC data source.
6 Numeric. The ODBC connection handle.
7 The null value.
APPLIES TO
- Microsoft Visual FoxPro 3.0 Standard Edition
- Microsoft Visual FoxPro 5.0 Standard Edition
- Microsoft Visual FoxPro 6.0 Professional Edition
- Microsoft Visual FoxPro 7.0 Professional Edition
- Microsoft Data Access Components 2.5
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate