Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Run a SQL Server 2005 stored procedure?
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01268987
Message ID:
01268992
Views:
15
>>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
Previous
Reply
Map
View

Click here to load this message in the networking platform