Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ODBC error and AERROR()
Message
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00052673
Message ID:
00052742
Views:
31
>Hi everybody,
>
>I am using SQL passthrough for a query to SQL Server. When I hit a connectivity error and try to get the error messages through AERROR() the array doesn't get created. More specifically, I get a connection handle, but don't get a result set (due to server side problems). If I run this code from the command window, AERROR(laerror) will create the array exactly like it is supposed to, but running it from the .prg doesn't work.
>
>My code is below:
>
>lcsql = DBGETPROP('cnstproj', 'view', 'sql')
>lcsql = STRTRAN(lcsql, '?SYSCODES', syscodes)
>
>lnhandle = SQLCONNECT(datasource, username, password)
>public laerror(1)
>IF lnhandle > 0
> * we have a connection
> lnsuccess = SQLEXEC(lnhandle, lcsql, 'cnstproj')
> =SQLDISCONNECT(lnhandle)
>ELSE
> lnsuccess = -1
>ENDIF
>IF lnsuccess < 1
> AERROR(laerror)
> ** do something with it
>ENDIF
>
>Any ideas?
>
>Thanks much.


STORE SQLCONNECT('DSNNAME','','') TO gnConnHandle
IF gnConnHandle <= 0
= MESSAGEBOX('Cannot make connection', 16, 'SQL Connect Error')
ELSE
= MESSAGEBOX('Connection made', 48, 'SQL Connect Message')
ck=SQLEXEC(gnConnHandle,mysqlstatement,"myquery")
if ck=-1
= AERROR(aErrorArray) && Data from most recent error
? 'The error provided the following information' && Display message
FOR n = 1 TO 7 && Display all elements of the array
? aErrorArray(n)
ENDFOR
else


ENDIF

It's Time to get a gun.

That's what I've been thinkin.

I think I can afford one, If I do a little less Drinkin.

www.TrueGeeks.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform