Microsoft KB Archive/180028

= PRB: DBC With Stored Procedure Produces Error When Opened =

Article ID: 180028

Article Last Modified on 12/11/1999

-

APPLIES TO


 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q180028



SYMPTOMS
When you attempt to open a database container (dbc) that contains stored procedures, the following error can occur:

Object file c:\ .dbc was compiled in a previous version of FoxPro.



RESOLUTION
 Duplicate the database container copying all the files into a new database container in another folder. This includes files with a .dbc, .dct, and .dcx extension. On the development computer used for building executable files for remote sites, open the new database container with the newer version of Visual FoxPro. The database container now converts automatically. Run the program named Gendbc.prg located in the \Vfp\Tools\Gendbc folder. Select the .dbc file in question and remember the name and location of the output .prg file it creates.  Open the .prg file created by Gendbc.prg and copy the code that resembles the code below.

NOTE: In the following code Test.krt and Test.dbc should be replaced with the name that you gave the .prg file and the .dbc file. ********* Procedure Re-Creation ********* IF !FILE([Test.krt]) ? [Warning! No Procedure File Found!] ELSE CLOSE DATABASE USE 'test.dbc' g_SetSafety = SET('SAFETY') SET SAFETY OFF LOCATE FOR Objectname = 'StoredProceduresSource' IF FOUND APPEND MEMO Code FROM [Test.krt] OVERWRITE REPLACE Code WITH SUBSTR(Code, 70, 66) ENDIF LOCATE FOR Objectname = 'StoredProceduresObject' IF FOUND APPEND MEMO Code FROM [Test.krt] OVERWRITE REPLACE Code WITH SUBSTR(Code, 136) ENDIF SET SAFETY &g_SetSafety USE OPEN DATABASE [Test.dbc] ENDIF  Make a project and then create a .prg file within the project and paste the code copied from step 4 into the .prg file. Build an executable making sure that the file with the .krt extension, which was created by the Gendbc program, is placed in the folder with the database container that needs to be converted. When you run the executable in the folder where the old database container is located, the executable places the code from the .krt file into the memo field of the database container that needs conversion. When you run the executable that opens the database container, the .dbc file should open correctly.</li></ol>

<div class="status_section">

STATUS
This behavior is by design.

<div class="moreinformation_section">

MORE INFORMATION
This error occurs when the database container contains stored procedure code and you attempt to open the database container with an executable that was created with a version of Visual FoxPro older than the version used to create the database container.

The newer version of Visual FoxPro must compile the stored procedure code in the database container. This allows the database container to open properly. If the database container does not have any stored procedure code, it can be opened without an error because conversion is not needed.

If you open the database container in the development environment of the newer version of Visual FoxPro, then the stored procedure code is compiled automatically and the error does not occur.

The error can be eliminated by opening the database container in the development environment of the newer version of Visual FoxPro. However, this presents a problem for database containers that are at a remote site where a newer version of a Visual FoxPro run-time executable is shipped. Since the development environment of Visual FoxPro is not available, the executable cannot automatically compile the stored procedure code and the COMPILE DATABASE command returns a "Feature not available" error message when used.

You can create a separate executable to convert the database container by following the steps in the RESOLUTION section.

Steps to Reproduce Behavior
<ol>  Create a database container in Visual FoxPro 3.x by typing the following in the FoxPro Command window: CREATE DATABASE old_vfp </li>  Next, in the Command window type: MODIFY DATA </li> Click the right mouse button (called right-click) while the mouse pointer is in the database container. Select the New Table menu option to build a new table called OLD_TABLE in the database container.</li> Add a couple of fields to the table, save the table, and then add a couple of records to the table.</li>  From the Visual FoxPro menu bar, select the Database menu option and choose the Edit Stored Procedures menu bar. Type the following: PROCEDURE my_proc WAIT WINDOW "In my Stored Procedure" </li>  Create a project in the newer version of Visual FoxPro and add a .prg file with the following code: OPEN DATABASE old_vfp USE old_table BROWSE </li> Select the Build button on the project to create an executable file. Place the executable file in the same folder that contains the database container and run the program outside the Visual FoxPro environment.

The error "Feature not available" appears.</li></ol>

Keywords: kbprb kbcode KB180028

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.