Page 1 of 1

TXT with ODBC

Posted: Fri May 29, 2009 2:31 pm
by Vanguarda
Hi my friends,

I want import a file TXT for a table in MySQL, so
try open a file TXT with ODBC, but it don't work with me.

Someone can say because it not work??
what is my mistake?

Please see the attachment

with best regards,

Re: TXT with ODBC

Posted: Fri May 29, 2009 5:18 pm
by luisvasquezcl
Hi Vanguarda

This function is ok
Function Abrir
LOCAL x := Getfile ( { {'Arquivo Texto','*.TXT'} } , 'Abrir Arquivo' )
LOCAL cConStr := "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=c:\hmg\samples\importTX;Extensions=asc,csv,tab,txt;"
LOCAL oConexao := TODBC():New( cConStr )
LOCAL cFile

cFile = Subs( x, Rat('\',x)+1)

oConexao:SetSQL( "SELECT * FROM "+cfile)
oConexao:Open()
Main.Grid_1.DeleteAllItems
for i= 1 to len( oConexao:aRecordset)
Main.grid_1.additem( {str(oConexao:aRecordset[i,1])} )
next
oConexao:Destroy()

return nil

Regards,
Luis Vasquez

Re: TXT with ODBC

Posted: Fri May 29, 2009 11:17 pm
by Vanguarda
Thank friend Luis,

I not have words for thanks... you are very amazing man.

Thanks a lot


with best regards,