Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Run a SQL Server 2005 stored procedure?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01268987
Message ID:
01268992
Vues:
16
>>I have some stored procedures in SQL 2005. Is there a way to run these from VFP? If so, is there a way to pass a parameter to it?
>>
>>Thanks!
>
>Sure:
>
>* 1. passing some constant as a parameter using named parameters
>SQLEXEC(sqlHandler, [EXEC YourSP @SomeParameter1=constant1,@SomeParameter2=constant2])
>
>* 2. passing some constant as a parameter using positional parameters
>SQLEXEC(sqlHandler, [EXEC YourSP constant1,constant2])
>
>These constants can be anything, direct values, or if you build the string before SQLEXEC values from some variables/fields:
>
>
>SQLEXEC(sqlHandler, [EXEC YourSP @SomeParameter1=1,@SomeParameter2='blah blah'])
>
>* 2. passing some constant as a parameter using positional parameters
>SQLEXEC(sqlHandler, [EXEC YourSP 1,'blah blah'])
>
>*** building the string bewfore SQLEXEC and using variables/fields
>TEXT TO lcSQL NOSHOW TEXTMERGE
>     EXEC YourSP <<variable_field1>>,'<<variable_field2>>'
>ENDTEXT
>SQLEXEC(sqlHandler, lcSQL)
>
>
>Of course you could use parameters :-)
>*** building the string bewfore SQLEXEC and using variables/fields
>TEXT TO lcSQL NOSHOW TEXTMERGE
> EXEC YourSP ?variable_field1,?variable_field2
>ENDTEXT
>SQLEXEC(sqlHandler, lcSQL)
>
>By using parameters (that little question mark) you dosn't care about proper type convertion VFP handle this, you are less vulnerable for SQL injections.

Thanks!
ICQ 10556 (ya), 254117
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform