>How do you trap an error generated by SQL server in Visual Foxpro 6.0 when there is a problem connecting to SQL server so Foxpro error handling routine will catch it before SQL throws a message box on the user's machine with an error. For example, Connection Failed because of SQL Server Error 18456 or Error 4060. Help please.....
Try this
LOCAL lnH
LOCAL ARRAY laErr[1]
lnH = 0
SQLSETPROP(lnH,'DispLogin',3)
lnH = SQLCONNECT("myDriver","myUsername","myPassword")
IF lnH < 0
AERROR(laErr)
MESSAGEBOX(laErr[3],16,"Database connection fails")
ELSE
MESSAGEBOX("Database connection Ok",64,"Ok")
ENDIF