> dear fox pro experts, i'm trying to insert data from cursor that i got from odbc.
>
>
> lcXLS file = getfile()
> lnConn=SQLSTRINGCONNECT("Driver={Microsoft Excel Driver (*.xls,*.xlsx,*.xlsm,*.xlsb)};DBQ=&lcXlsFile")
> SQLCOLUMNS(lnconn,"[sheet1$]",'NATIVE','crscolumns')
>
> SQLTABLES(lnconn,"","sheetnames")
> scan
> lctablename=trim(sheetnames.table_name
> lcoutput=chrtran(m.lctablename,'$','_')
> SQLEXEC(lnConn,'select * from ['+m.lctablename+']',m.lcoutput)
> endscan
>
> how could i retrieve column name from m.lcoutput into column in a dbf table
>
>
> select * from &lcoutput into cursor tr
> select tr
> go top
> do while !eof
>
> insert into mytable (col1,col2,col3) values * how to get the column of cursor tr
> enddo
>
>
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