Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can I change a fieldname - programatically
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01439486
Message ID:
01439752
Views:
47
Good idea! I implemented my solution thusly...

All fields returned with afields... I change the name of the field to _fname001,_fname002,_fname003,... where fname is the name returned. the _ at the start solved the invalid fieldname and the 001... makes sure the field name is unique...

Then I create a new table from the new afields and populate it via scanning through the table and scattering the fields to an array and then inserting the values into the new table.


It works with fields no field name spreadsheets i.e. with no first row, with field names starting with an invalid character, and with spreadsheets with valid field names as well.

Thank you Ian,
Mike

>Hi Mike.
>
>I don't think that you will be able to field the field name programatically since, because the field name is invalid, you won't be abel to reference it.
>
>I'd suggest that you use AFields to read the structure, change the names in the array that are invalid, use that to create a cursor and then append from the cursor with the invalid field names. If the Append From fails because it sees the invalid names, then I'd try copying the data into an array and appending from that to see if that gets around it.
>
>Ian Simcock.
>
>
>
>>If I try to brow the cursor, I get "The data source for this object must be a variable reference". error I am assuming this error occurs because the one field has a name of "800" i.e. in the code above the lcFldName is "800" and lcNewFldName would be "_800" which would be a valid field name.
>>
>>Does the above help?
>>Thanks again,
>>Mike
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform