Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Remote View or SQL Passthrough?
Message
From
01/12/2010 18:41:25
John Ryan
Captain-Cooker Appreciation Society
Taumata Whakatangi ..., New Zealand
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01491428
Message ID:
01491488
Views:
57
>>What is the best way to handle SQL Server data on a form, with a Remote View, or SQL Passthrough?

SQL Pass-through (SPT) allows maximum flexibility since you can build any imaginable query. RV is less flexible since the field list and WHERE clause generally is fixed, but it has other advantages:

1) SQL Injection-proof
2) Automatic change management
3) Compilation of stereotyped queries by SQL Server, for better efficiency.
4) databinding at design time and retained on requery()

1) matters a lot and is well worth reviewing closely, especially if you are building your SPT by concatenating- e.g.
lcSQL=[select * from dbo.mytable where username=']+lcusername+[']
... that sort of query is highly vulnerable to injection. Injection is easy enough to prevent in VFP by using parameterized queries rather than concatenating SQL- e.g.
select * from dbo.mytable where username=?lcusername
Parameterized queries also are compiled by SQL Server for reuse, leading to better efficiency.

2) Is important as well, since you can edit one or more fields in one or more rows in a RV and have the changed fields automatically saved to the backend, without having to save the whole record/resultset or write your own change management code.

3) is simply that RV's parameterized queries are compiled and reused by SQL Server since (from memory) version 7.

4) is that RVs are very available for grids, controlsources etc at designtime, with the controlsources, designed grid columns etc retained when you requery() the RV. Compare this to the behavior if you use a SPT cursor and recreate it.

>>Also, when you use SQL Server in a Form's Grid control, how much of the data actually comes across the network to the workstation where the user is utilizing a VFP form? Does the data end up in the temp files, until saved and then altered on the SQL tables immediately or later, upon saving?

The data is in a plain cursor that spools to disk as necessary. In a RV, field edits are recorded and uploaded depending on the buffering you select and the update settings in the RV. If (for example) a 1-character field is changed in a RV, by default updating will send back only that one field, which is very efficient and essentially free of charge to the developer. FWIW you can mimic this behavior in a SPT cursor or any other sort of VFP cursor: check out cursorsetprop() for this purpose.

Re cursor adaptor: see http://fox.wikis.com/wc.dll?Wiki~CursorAdapterOrNot
"... They ne'er cared for us
yet: suffer us to famish, and their store-houses
crammed with grain; make edicts for usury, to
support usurers; repeal daily any wholesome act
established against the rich, and provide more
piercing statutes daily, to chain up and restrain
the poor. If the wars eat us not up, they will; and
there's all the love they bear us.
"
-- Shakespeare: Coriolanus, Act 1, scene 1
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform