How do I upgrade DBI Components in my VFP application?


When updating existing VFP forms with new components, you may receive OLE errors informing you that the new components are being ignored.

OLE error code 0x"name" :
Unspecified error. OLE object is being Ignored.
Record number "x".

When you open the forms, you will see that, in fact, the components in question are missing from your form.

Not all updated components will cause this error. The error will occur when an object has been fundamentally changed (i.e. a new method or event has been added) and the component's wrapper (a map to the component's functionality that managed by VFP) has become outdated.

Other platforms such as Visual Basic are able to incorporate these changed components without difficulty. In the case of Visual Basic, component "wrapper" information (an "OCA" file) is dynamically updated by VB. VFP, on the other hand, stores component wrapper information within the form's underlying structure. Unlike VB, VFP does not dynamically update the wrapper information.

Fortunately, FoxPro's open architecture provides easy access to the code and properties of the missing objects. Characteristics of FoxPro forms are maintained in FoxPro tables with standard DBF structure … but with an SCX extension: i.e. "<FORM_NAME>.SCX"

The following procedure makes use of this open architecture to replace the code into the new objects:

  1. Save your code to a temporary table
  2. From the project manager, open the form in question and note each record number displayed at the end of each occurrence of the error message box.
  3. Close the form without saving it.
  4. From the "Window" menu , select the "Data Session" option.
  5. On the "Data Session" window , click the "Open" push button.
  6. In the file "Open" dialog, click the "Other…" push button.
  7. In this second file "Open" dialog, select "Files of type: All Files".
  8. Navigate to the path and file name (SCX) for your form. (i.e. <my_form>.SCX)
  9. Select the <form_name>.SCX and click the "Open" push button.
  10. From the "Data Session" window, click the "Browse" push button. 10. For each record number noted from the error message box, copy the table information to a temporary file.
        For example:
    "copy for recno()= 6 .or. recno() = 10 to temp"
    You now have preserved the notes on properties, the code for the methods and events. Each record line contains all the  code and property information, in Memo fields, that you had saved with the old object(s).
    Browse and note especially the fields:
    · Objname (the name that you specified for the object)
    · Properties (a listing of the properties that you specified on the properties sheet for that object)
    · Methods (a listing of all the events and associated code for the object)
  11. Close your <form_name>.SCX table. (Leave the temporary table open)

Restore your code to the updated components:

  1. In your project window, open your form again.
  2. Insert the new objects where the old objects had been.
  3. Modify the properties for the new objects.
  4. Edit the code the for the new objects.
  5. Open the "Methods" memo field in the temporary table.
  6. Switching between the "Methods" field and the events in your object code, cut and paste your code back into the new object. Repeat code cut-and-paste for each new object.