Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Use of procedure,views and functions of sql server in vf
Message
From
20/09/2005 14:40:43
 
 
To
20/09/2005 10:46:45
Atif Saeed Khan
Nextbridge Prvt Ltd.
Lahore, Pakistan
General information
Forum:
Visual FoxPro
Category:
Client/server
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows 2000 SP4
Network:
Windows 2000 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01051303
Message ID:
01051401
Views:
13
>hi!
>
>i want to manipulate the most of the work through the sql server stored procedures, views and functions. will u plz tell me is it the rite professional way to do the client/server programming ?
>
>1 - will you plz tell me how can i use a parameterized procedures (input / output) both from the vfp.
>2 - how to use the sql server views in vfp
>3 - how to use the sql server functions in vfp
>
>thanks n regards.
>atif saeed khan

All of these things can be accomplished with SQLEXEC() and other SQL...() functions from VFP.

To make a connection, you can use SQLSTRINGCONNECT():
cConnString = "Driver={SQL Server};server=YourServerName;uid=sa;pwd=YourPassWord;database=YourDataBase"
nSQLHandle = SQLSTRINGCONNECT(cConnString)
Parameterized procedures and calling SQL Server functions and/or stored procedures:
cSQL = [EXEC InsertRecord ?thisform.MainID,?cNewPhone,?@thisform.TNID]
nStat = SQLEXEC(nSQLHandle,cSQL)
Note the use of "?@" for the return value from the procedure "InsertRecord" or whatever your names are.

If you need to just retrieve records from SQL Server into a VFP cursor, it's:
cSQL = [SELECT * FROM YourTable WHERE SomeField='some value']
nStat = SQLEXEC(nSQLHandle,cSQL,"CursorAlias")
You can do UPDATE statements via SQLEXEC also.
cSQL = [UPDATE YourTable SET SomeField='some value' WHERE KeyField=?YourKey]
nStat = SQLEXEC(nSQLHandle,cSQL)
If you check the return values of nStat from a SQLEXEC call and it's not a value of 1, then you'll need to use AERROR() to see what happened on the SQL side.

And to disconnect:
SQLDISCONNECT(nSQLHandle)
Fred
Microsoft Visual FoxPro MVP

foxcentral.net
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform