Text files can also be accessed by using the ADO objects. Following is the code for the same: 'Connnection Objects Dim conn Set conn=CreateObject("ADODB.connection") 'Create the DSN for the text file, defualt directory is poiting to the location where flat file is kept conn.open "DefaultDir=C:\Users\sandeep\Desktop\Blog R & D\ADO Flat File;Driver={Driver da Microsoft para arquivos texto (*.txt; *.csv)};DriverId=27;FIL=text;FILEDSN=C:\Users\sandeep\Desktop\Blog R & D\ADO Flat File\Flt.dsn;MaxBufferSize=2048;MaxScanRows=8;PageTimeout=5;SafeTransactions=0;Threads=3;UID=admin;UserCommitSync=Yes;" 'Recordset object Dim rs Set rs=CreateObject("Adodb.recordset") strQry="Select * from SampleTextFile.txt" ' Execute query rs.Open strQry,conn ' Loop and get the records from the flat file Dim counter Do counter= counter+1 For i=0 to rs.Fields.Count-1 If counter=1 Then print rs(i).name print r...
Comments
Post a Comment