Tonight’s meeting of the Seattle VFP Special Interest Group was disappointing. Not because of the content, but because so few people braved the elements to come out and see it. When I’m the one presenting, that’s fully justified. :-)
Tonight, though, Aleksey Tsingauz, of the Fox development team, walked us through the use of CursorAdapters. CursorAdapters are object wrappers for data connections. Where views can only do local and ODBC data sources, CAs can connect to native, ODBC, ADO, or XML data sources with equal fluency. Aleksey showed us the main properties, grouped by topic. There are (can be, actually) custom commands for Inserting, Updating, or Deleting data, and you can hook in Before or After the command fires. You can also do automatic transforms on the data using the ConversionFunc property: Aleksey’s example was ALLTRIMming Fox character fields to go into SQL Server varchar fields.
Cursors can be attached to and detached from CA objects at will. If the cursor is not compatible with the object and you’re using the automatic functions, rather than custom-coding them, it will be rejected. However, if you’ve written the custom functions, your Customer CA object will be perfectly happy attaching to your Employee cursor.
The AfterCursorFill event can be used to create indexes for your cursor, among other things.
BeforeUpdate lets you see the actual command which is being sent to the back end. This is useful for troubleshooting. AfterUpdate lets you overrule failures. It has an lResult parameter that is passed by reference, so that if you can repair the failure, you can flip the flag so that the TABLEUPDATE() function reports that the update succeeded. The various events fire once per row updated, unless you set the CA into batch mode — I didn’t quite get the syntax for this.
Aleksey then proceeded to demonstrate the various PEMs he had been explaining.
One thing that came out during the demos was that the various DataSourceTypes (Select, Insert, Update, and Delete) do _not_ need to match. You could have the select going through ADO, and an update going through ODBC. You could even write a native function that would process the update and then pass it back to the server.
He also demonstrated accessing the data through Stored Procedures on the back end. This is something you can _not_ do with remote views, though you can write lots of code to do it with SQL pass-through.
All in all, an informative and satisfying meeting. Next month on the 17th, Richard Stanton will be previewing some of the new reporting features in Europa, the upcoming version of Visual FoxPro. This will be a don’t-miss meeting, so mark your calendars!
For more information about CursorAdapters, see the online documentation at MSDN. Aleksey will be sending his slides and demos in the near future to be posted on the SeattleVFP.org site.