Microsoft KB Archive/134643

= FIX: Alter Table Add Primary Key Error Not Trappable =

Article ID: 134643

Article Last Modified on 9/30/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition

-



This article was previously published under Q134643



SYMPTOMS
When an existing ON ERROR routine is in effect, the following command causes an error, but that error is not trapped by the error routine.

ALTER TABLE ADD PRIMARY KEY

Instead running the error handler, Visual FoxPro presents a message box titled "Microsoft Visual FoxPro" that contains the message "Primary key already exists," and it offers the options of OK and Help.

The Help text topic states:

Primary key already exists. (1883)



STATUS
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem has been corrected in Visual FoxPro 5.0 for Windows.



Steps to Reproduce Problem
  Write a simple program, such as the following program, to illustrate this error and the error as it should be handled. ON ERROR WAIT WINDOW "Error" switch=.F.  OPEN DATABASE C:\VFP\Samples\Data\testdata.dbc SELECT Customer DO WHILE .T.    IF !switch ALTER TABLE Customer ADD PRIMARY KEY cust_id ELSE ALTER TABLE Customer ADD cust_id PRIMARY KEY ENDIF switch=!switch ENDDO  Name this program Altertst and save it. In the Command window, enter the DO Altertst command. Press ENTER at each pause After successfully observing the two error modes, press ESC to cancel. In the Visual FoxPro default directory, you will find an error log created in response to the ON ERROR handler named Altertst.err. This is a text file and may be read. It will have the offending line number and the report that the line has a syntax error.</li> Rerun the program. When the Microsoft Visual FoxPro message box appears, click the Help button to see the help text.</li></ol>

Additional query words: 3.00 5.00 handler

Keywords: kbbug kbfix kbvfp500fix KB134643

-

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

© Microsoft Corporation. All rights reserved.