rebuilding network here, only Linux lap up... IAC I'd
BEGIN TRANSACTION
BEGIN TRY
SELECT 1/0;
COMMIT TRANSACTION
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION;
THROW;
END CATCH
>>>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
>
>If this is a bit of SQL, what do you get in your la_Error?
>
>
BEGIN TRY
> BEGIN TRANSACTION
> SELECT 1/0;
> COMMIT TRANSACTION
> END TRY
> BEGIN CATCH
> ROLLBACK TRANSACTION;
> THROW;
> END CATCH