Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cursoradapter and Selectcmd
Message
From
07/03/2010 23:35:40
 
 
To
07/03/2010 06:36:50
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01452991
Message ID:
01453105
Views:
63
>Hi
>
>I have successfully created a CursorAdapter class, using this tutorial: http://www.foxite.com/articles/read.aspx?id=49&document=creating-using-cursor-adapter-classes-a-simple-tutorial
>
>I can build the SQL statement on the fly, using the properties of the builder above, i.e. declaring the SQL command and sort/filter properties, I have placed the new CA with the data environment of my form, modified the data specific properties, and I have tested the connection. The new class works perfectly and returns the exact data that I need into a cursor that I can the bind to controls on myForm.
>
>However, what if I wanted to use SelectCMD to run an already created stored procedure with SQL Server 2005? The stored procedure has a parameter, CandidateID, so I'd need to pass that via SelectCMD.
>
>Regards

Dereck

Check out the following Methods of the CA

BeforeUpdate
LPARAMETERS cFldState, lForce, nUpdateType, cUpdateInsertCmd, cDeleteCmd


BeforeDelete
LPARAMETERS cFldState, lForce, cDeleteCmd

BeforeInsert
LPARAMETERS cFldState, lForce, cInsertCmd

In all cases this method is run first. So you hook into these methods and change the cUpdateInsertCmd, cDeleteCmd, cInsertCmd

for instance in the BeforeInsert
BeforeInsert
LPARAMETERS cFldState, lForce, cInsertCmd
* code here to check whether you want class or custom selectcmd. using SQLEXEC

* call the SP including parameters exaclty as you would have done
cInsertCmd = "Your custom SQL statement "

DODEFAULT(cFldState, lForce, cInsertCmd)
You could add 2 custom properties - cInsertOverrideStatement and lInsertOverride(.T./.F.)

Then in your code you give this property a value and set the flag to .T. ot .F. . In your BeforeInsert you check this flag and change the cInsertCmd parameter, if needed before passing them along using DoDefault.
BeforeInsert:

LPARAMETERS cFldState, lForce, cInsertCmd
IF This.InsertOverride
    cInsertCmd  = This.cInsertOverrideStatement
ENDIF
DODEFAULT(cFldState, lForce, cInsertCmd)
Bernard ( author of that article)
Previous
Reply
Map
View

Click here to load this message in the networking platform