View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Fredrik Wahlgren Fredrik Wahlgren is offline
external usenet poster
 
Posts: 339
Default Excel VBA - CopyFromRecordset (ADO) Problems with 107000 recor


"Philip" wrote in message
...
Hi,

Well, files containing 65536+ records need to be imported into MS Excel

for
checking.

I agree that Access would be a nice option, but it isn't an option as the
person checking the data won't have MS Access.

So I decided to use ADO as File I/O is unbelievably slow - for example,

why
read a file line by line when you can read the entire file using ADO /

ODBC
in 3 seconds then use Excels 'CopyFromrecordset' method to dump it into

MS
Excel...where the data has to be.

Anyway, I solved it... it turns out that the behaviour (seems to be
undocumented!) of the CopyFromRecordset method is to take the first 65536
records, and move the recordset pointer to the first unread record...

so in fact all I have to do is loop unti EOF, and in the loop add a new
sheet, rename it, and call CopyFromrecordst again...

nice!

Thanks anyway :)


Maybe this solves th problem in a way. Maybe there's an easier way. I have
never used SQL to get data from a txt file,anyway depending on what kind of
checking you are doing, maybe it's possible to make a smarter SQL statement
that selects the records that have some kind of error in them.

So.. What kind of checking do you do?

/Fredrik