>>>>Hi Kevin
>>>>
>>>>In message #
01679403 I am trying to get SQL Server to execute a command via SPT and if the command fails, send an error to VFP.
>>>>
>>>>The app I inherited is doing SQLEXEC without any checking of return values. I am building a little ??sqlexec in which I will check and re-establish a broken connection, check and retry for busy connections. I was prompted to use a transaction around the existing query.
>>>>
>>>>Can you advise?
>>>>
>>>>Thanks
>>>>
>>>>Mike
>>>
>>>Mike
>>>
>>>I'm not sure if this will help, but this is a function that has been working for a long time in my apps.
>>>I only use SPT.
>>>
>>>
>>>
>>>*-- Execute SQL Command and display errors, if any
>>>PARAMETERS pc_ConnHandle
>>>PRIVATE ll_return, ln_exec,la_error
>>>ll_return = .T.
>>>ln_exec = SQLEXEC(pc_ConnHandle)
>>>IF ln_exec < 1
>>> ll_return = .F.
>>> WAIT WINDOW "SQL ERROR Has Occurred "
>>> = AERROR(la_error)
>>> WAIT WINDOW la_error(1,2)
>>>ENDIF
>>>RETURN ll_return
>>>
>>
>>Hi Bill
>>
>>No, not quite enough, thanks. I want to do more than that. I want to add a transaction to whatever sqlexec is being attempted. The app does not sqlprepare every query. I just noticed that RAISE ERROR is badly spelled. Microsoft in their infinite wisdom made it RAIS ERROR.
>>
>>Now that I see that, I can go on to trigger an error. Sheeeeeesh.
>
>You can also use TRY/CATCH/THROW in SQL Server 2016 and up.
If you had looked at the first thread, you'd know I am.