Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting SQL Server stored proc return value
Message
De
07/12/2003 17:37:21
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Divers
Thread ID:
00856398
Message ID:
00856730
Vues:
19
Hi Sergey

>Sorry, but it still doesn't work. First, it pops up View parameter dialog. If I enter anything, ODBC error is generated "[Microsoft][ODBC SQL Server Driver][SQL Server]Procedure proc_test has no parameters and arguments were supplied".

My fault - I assumed you knew about this one - I wasn't being very clear - sorry.

You actually have two things going on here.

[1] You must declare the parameter as OUTPUT in the Stored Procedure.
[2] Second you must initialize the privvate variable because unlike a LOCAL or PUBLIC declaration, VFP doesn't actually create the variable when you merely use PRIVATE. Try the following:
/* IN SQL SERVER (Query Analyzer), SELECT "MASTER" DATABASE and execute the following */
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[test]') 
                    AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
  DROP PROCEDURE [dbo].[test]
GO

CREATE PROCEDURE test @retval CHAR(2) OUTPUT 
AS 
SELECT @retval = xtype from sysobjects WHERE id = 1
GO

/* END OF SQL SERVER STUFF */

*** NOW IN VFP RUN THE FOLLOWING CODE WITH A LOGIN THAT WILL GET YOU ACCESS ***
gnCon = SQLCONNECT( [DSN], [UID], [PWD] )
SQLEXEC( gnCon, [USE Master] )
PRIVATE luRetVal
luRetVal = ""
? SQLEXEC( gnCon, [EXEC test ?@luretval] )
*** Should show "1" and now
? luRetVal
*** Should show "S"
----
Regards
Andy Kramek
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform