My SQL Function is AS follow:
Function GetClientName (@ClientId Char(10))
Returns char(20)
AS
BEGIN
DECLARE @ClientName as varchar(20)
set @ClientName = (Select LastName from Clients where ClientId =
@ClientId)
RETURN @ClientName
END
In FoxPro I use:
lnRetVal = SQLEXEC(pnHandle,"SELECT dbo.GetClientName('0000000101') AS
ClientName", "sqlClientName") - which returns -1
when I use SELECT dbo.GetClientName('0000000101') AS ClientName in query
analyser it returns last name of the client!
Am I missing anything?
Thanks for looking it.
-Anders
"Sunny" <sunny...@hotmail.com> wrote in message
news:eHTNWjs5...@TK2MSFTNGP06.phx.gbl...
> In FoxPro I use:
>
> lnRetVal = SQLEXEC(pnHandle,"SELECT dbo.GetClientName('0000000101') AS
> ClientName", "sqlClientName") - which returns -1
Take a look at the help on SQLEXEC().
Return Value:
Numeric data type. SQLEXEC( ) returns the number of result sets if there is
more than one.
SQLEXEC( ) returns 0 if it is still executing
and returns 1 when it has finished executing.
SQLEXEC( ) returns -1 if a connection level error occurs.
SQLEXEC will never return the result of the
executed T-SQL or UDF executed. That result
you search for will always be in a result CURSOR,
which SQLEXEC creates.
As you found out yourself the -1 return value was
a sign, that something didn't work, in your case
insufficient access rights.
You can also use AERROR() after -1 is returned from
SQLEXEC() to get the error that occured.
Bye, Olaf.