Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to use Access database fields starting with a digit
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00380430
Message ID:
00381032
Vues:
13
>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!
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform