> >
> > You can use AFields() to determine column names.
> >
> > If you'd be using VFP9, and given that the XLS has three columns only, and if you want to import into an existing table, you could probably use the * placeholder:
> >
> > Insert Into mytable (col1,col2,col3) Select * From ...
> >
> >
> > If the table does not exist yet, you can:
> >
> > Select * From ... Into Table newtable
> >
> >
> >
> >
> > hth
> > -Stefan
>
> stefan i use vfp7, this code
>
>
> Insert Into mytable (col1,col2,col3) Select * From ...
>
> occurs an error with syntax error,
Yes, it's Vfp9 syntax.
> and i use afields() already, but the column name that showed from afield cannot be called using sql syntax, i dont know why..
>
You can perhaps concatenate a string, i.e. an SQL command, and then run it via ExecScript() or ¯o:
* Command Window example createing an SQL field list on the fly:
CREATE CURSOR temp (unknown i, fieldnames i, inthelist I)
? AFIELDS(laFields,'temp') && 3
DISPLAY MEMORY LIKE laFields
lcSQL = ""
FOR lnField = 1 TO ALEN(laFields,1)
lcSql = lcSql + IIF(EMPTY(lcSQL),'',',')+laFields[m.lnField,1]
ENDFOR
? lcSQL
lcSQL = "Select " + m.lcSQL + " From temp"
&lcSQL
hth
-Stefan