Sergey,
Sorry, this code is somewhat scaled down. The test I was running had the id_field as REGULAR, not PRIMARY and did contain duplicate values. It should encounter error 1884
thanks,
jfh
>John,
>
>There's no provision in your code for errors other than 1705 and 1884. In that case lcErrorInfo variable isn't assigned any values.
>
>>Hello all,
>>I'm messing with an indexing routine and wrapping it in a TRY CATCH:
>>
>>
>>TRY
>> ALTER TABLE myTable ADD PRIMARY KEY id_MyTable TAG id_MyTable
>>CATCH TO oException
>> DO CASE
>> CASE oException.errorno = 1705
>> lcErrorInfo = 'Somebody has the table open.'
>> CASE oException.errorno = 1884
>> lcErrorInfo = 'When trying to index the primary key, duplicate entries where found.' + CHR( 13 ) ;
>>+ 'Please fix the data.'
>> ENDCASE
>>
>> MESSAGEBOX( 'A problem was encountered while indexing table ' + UPPER( ALLTRIM( pcTableName ) ) + ':' + CHR( 13 ) ;
>>+ ALLTRIM( oException.message ) + CHR( 13 ) ;
>>+ lcErrorInfo, 48 )
>>ENDTRY
>>
>>
>>Problem is, it doesn't catch. I've watched it through the debugger, it enters the TRY portion, runs the ALTER TABLE and immediately throw a default VFP error message up. Then it completely bypasses the CATCH. Am I missing something here? Thanks for any insight.
>>
>>jfh