I need to find the quickest way to replace my DB Access in a large, legacy VFP application. The primary objective is in finding a solid solution to get past the GB limitations of the VFP 9 database engine. The second greatest objective is to do so without a complete rewrite of the legacy access code.

I was hoping I could find a hybrid of middle ground that would suffice in the short term.

I've played with Cursor Adapters a bit, as well as Advantage OLE DB. I ran into several issues, particularly as these methodologies do not lend themselves to work well with legacy commands (Scatter, Gather, etc.), and I found that I could not reliably mix (trying to replace) the old index expressions with the new style expressions in indexes - and still be able to do a simple open in legacy VFP (I.E. I can't use my quick "BROWSE" command that I have scattered around the project).

I've finally realized that, in order to have a near 1-to-1 code replacement, I need to wrap the Ads Client API in home-grown access objects, so as to say replace the legacy "Use Index Alias Shared" statement with an equivalent Open function.

So having nearly completed a wrapper, I have a couple of issues bottlenecking my progress. 1. I need to replicate the functionality of the Scatter / Gather commands so as not to have to touch the memory variables in the many Forms throughout the project. 2. I need an optimized method of populating several VFP grids with data that can still be used to update these very large tables on the fly - hopefully optimized for ADS speed and without significant code changes.

Are there any suggestions or code bases that have tackled these issues that I may be able to draw upon?

asked 03 Jun '14, 13:46

gverge393's gravatar image

accept rate: 100%

Add a method to your class to gather field names into a class property named aFldsInfo. aFldsInfo gets loaded with field names right after opening the table successfully with code such as:

   ::aFldsInfo := ( ::cAlias )->( DbStruct() )
   ::aBuffer := Array( len( ::aFldsInfo ) )

Now you can add a new method to your class to scatter data from .dbf/.adt into a memory array ( ::aBuffer ) like this:

METHOD Scatter() CLASS txDbf
local nFor
local nLen := len( ::abuffer )

   for nFor := 1 to nLen

      ::aBuffer[ nFor ] := ( ::cAlias )->( FieldGet( nFor ) )
      ::aModify[ nFor ] := .f.


return nil

And finally a method to gather would simply write back from the ::abuffer array into the corresponding field-names on the table. Of course you can change .abuffer, .aModify, .aFldsInfo for whatever other nomenclature as expected by the rest of your code.


answered 09 Jun '14, 07:58

Reinaldo's gravatar image

accept rate: 6%

Your answer to the original question.
If responding to a request for additional information, please edit the question or use the comment functionality.
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 03 Jun '14, 13:46

Seen: 4,606 times

Last updated: 09 Jun '14, 07:58

Advantage Developer Zone Contact Us Privacy Policy Copyright Info

Powered by Advantage Database Server and OSQA
Disclaimer: Opinions expressed here are those of the poster and do not necessarily reflect the views of the company.