Hi Will,
Ok, mail this file to me with a little test program, I'll take a look. I don't have VFP7 here.
BTW, I also found a case of C0005 error on alter table command (in that case I was changing NULL value of fields). I reported this problem to MS several months ago, but haven't heard anything from them.
Recently I reported another bug, but heard nothing so far.
>Nadya,
>
>Thats interesting.. because I can and do change fields which are part of indexes.
>As long as you dont change a Numeric to a String which is referenced in an index as STR(x) it seems to be ok.
>
>Your solution would not work in this instance as the table or cdx appears to be corrupted (although I cannot generate any kind of problem apart from this one)
>As soon as I try to issue "alter table", VFP aborts abruptly or C00005 errors
>
>Will
>
>P.S. I can mail you the .zip if you would like to try your code on this table.. I think you will be surprised!
>
>>Will,
>>
>>You can not change field, which is part of index without deleting this index first. Here is the piece of code, which works for me in VFP6 SP4: (thanks to Trey Walpole for the idea)
>>********************************************************************
>>* Description.......: ChangeTable - run alter command
>>* Calling Samples...:
>>* Parameter List....: tcTableName, tcCommandStr
>>* Created by........: Nadya Nosonovsky 06/06/2001 10:16:59 AM (idea by Trey Walpole)
>>* Modified by.......:
>>********************************************************************
>>lparameters tcTableName, tcCommandStr
>>local lcOldError, llError, lcTag
>>lcOldError=on('error')
>>on error llError=.t.
>>* invoke the ALTER TABLE – SQL Command with &-macro expanded tail
>>alter table (m.tcTableName) &tcCommandStr novalidate
>>do while m.llError and oValid.lContinue
>> release laError
>> =aerror(laError)
>> if laError[1,1] = 1531
>> lcTag = laError[1,3]
>> set message to 'Deleting tag '+ m.lcTag
>> delete tag (m.lcTag)
>> llError = .f.
>> alter table (m.tcTableName) &tcCommandStr novalidate
>> else
>> exit
>> endif
>>enddo
>>if m.llError
>>** Exited
>> aerror(laError)
>> =messagebox("Error: " + transform(laError[1,1])+chr(13)+laError[1,2], 48,"Alter table error")
>>endif
>>*set message to ' '
>>on error &lcOldError
>>return m.llError
>>
>>
>>
>>>Hello all,
>>>
>>>I have recently been getting a lot of C5 errors when altering the structure of tables and think I have found the problem.
>>>
>>>When I try and run the following command in a loop I get a C5
>>>
>>>Alter table x alter column y n(3)
>>>
>>>The problem occurs when the field y is used in an index
>>>I have a few indexes which look like : field1 + str(y) + field3
>>>these seem to cause the most trouble.
>>>
>>>Has anyone else encountered anything like this?
>>>My workaround is to delete tag all & recreate but its a bit of a pain!
>>>
>>>Thanks
>>>
>>>Will
If it's not broken, fix it until it is.
My Blog