Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to use Access database fields starting with a digit
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00380430
Message ID:
00381032
Views:
12
>I have a lot of such fields and I don't know their exact names.
>I don't have Access installed.

My tip was meant to run from vfp, within the code you downloaded from MS.


>How to automate this process so that human intervention is not required ?

This is a shot in the dark, but you should be able to get the gyst of it...

instead of
lcSQLCommand = ;
"SELECT * FROM [" + ALLTRIM(SQLResult.table_name) + "]"

do something like this

lcSQLCommand = "Select "

for n = 1 to fcount( SQLResult.table_name)
if isdigit( left( field( n, SQLResult.table_name)))
* if field name is something like "1date",
* add "1date as _1date" to sql command

lcSQLCommand = lcSQLCommand + field( n, SQLResult.table_name)

lcSQLCommand = lcSQLCommand + " as _" + ;
field( n, SQLResult.table_name)

else
lcSQLCommand = lcSQLCommand + field( n, SQLResult.table_name)

endif
if n < fcount( sqlresult.table_name)
lcsqlcommand = lcsqlcommand + ", "
endif
next


Hope this helps!

Alex



>
>
>>You need to make the code you posted a bit less "brute-force-ish" if you want to do this.
>>
>>Try to see if you can get the field names of the access table through code, and instead of having the program create a "select * from yadayada" statement, build the sql statement field by field and whenever you find a field that starts with a number, make your add ' as "x" + fieldname'
>>
>>That way the select will create a cursor with field names that work within a dbf structure.
>>
>>Alex
>>
>>
>>>I have a table in MS Access MDB file and want to convert it into
>>>VFP table.
>>>I use samle code from
>>> http://support.microsoft.com/support/kb/articles/q260/4/05.ASP
>>>
>>>However, filed name in access table starts with a digit.
>>>This causes this MS sample program to fail: accessing such field is
>>>not possible. I want to add an underscore character to start of suht fields.
>>>How this can be done ?
Low-carb diet not working? Try the Low-food diet instead!
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform