Friday, June 25, 2010

Gotcha with Custom Report Memberdata Attribute Names in VFP 9 SP 2

(That must be the longest blog title in history!)

I’ve been (finally) implementing VFP 9 SP2 features in Stonefield Query (version 4.0 is due to be released next week) and, while doing some final testing, ran into an error when editing a certain object in the Report Designer. The error was 1712, “Field name is a duplicate or invalid”. In tracking the error down, it occurred in the XMLStrToCursor method of _FRXCursor, one of the report helper classes in the FFC. The statement causing the error was ALTER TABLE … ADD COLUMN … It’s not actually a table that columns are being added to but a cursor. The weird thing is that the columns being added didn’t exist in the cursor, so they certain weren’t duplicates.

I tweeted about this and Frank Perez Jr. responded “I think you also get that error if the field name is invalid (i.e. more than 10 characters in a free table).” Sure enough, that was the problem. Even though cursors can have field names longer than ten characters, ALTER TABLE can’t handle them, and given that there’s no ALTER CURSOR command, we’re stuck with it.

What lead to the error was that I added custom report memberdata to the specific object causing the problem. The custom memberdata had an attribute named “adjustwidth”, which is more than ten characters long. Changing it to “adjwidth” solved the problem. So, important safety rule (channelling Venkman here): don’t use names more than ten characters for your custom report memberdata attributes.

Thanks to Frank for pointing me in the right direction. Another reminder of the usefulness of Twitter.

No comments: