>hi,
> How can i execute a sql stored procedure with parameters from VFP?
>
> I have a stored procedure in sql server with 2 inputs parameters and 1 output parameter how can i execute & retrieve the value in output parameter from VFP. Is there a way to trap SQL or ODBC error msgs from VFP?
>
>sanjay.
Sanjay,
Let me jump into this even though it looks like it has already been answered.
First, the errors. Reading your other messages, it looks like you are using RAISERROR() to return an error from your SP. Make sure the severity level is configured high enough for SQL Server to generate an error. The level must be higher than 10 in order for SQLExec() to return a negative value and populate the information for Aerror() to pick up.
To return a value, you must pass it in by reference and then set it in you SP. Ex.
local lx, ly, lz
lx = 'Fred'
ly = 22
lz = ''
if sqlexec(lnconn, [exec mySP ?lx, ?ly, ?@lz]) < 0 then
=aerror(laerror)
else
endif
The above VFP code was used with the following example SP:
CREATE PROCEDURE testoutput
@var1 varchar(10),
@var2 int,
@var3 varchar(10) OUTPUT
AS
if upper(@var1) = 'FRED'
set @var3 = 'Astaire'
else
set @var3 = 'Unknown'
HTH.
Larry Miller
MCSD
LWMiller3@verizon.netAccumulate learning by study, understand what you learn by questioning. -- Mingjiao