odbc & stream & excel file

R

rob

I have to read a csv file. In order to avoid all the hassle with the
parsing (some items are in quotes, others are not, some have
quotes/comas in the items themselves, etc) I simply use odbc. The code
is shown bellow. The problem is that the source is actually a string (a
csv file downloaded from the internet via
WebResponse->GetResponse->GetResponseStream->ReadToEnd). So in order to
read it through odbc I have to store the string to a file just so that
I can pass the file to the ctor of OdbcConnection. Is there a way I can
avoid having to create a temporary file?

Thanks

connectionString = @"Driver={Microsoft Text Driver (*.txt;
*.csv)};DBQ=" + Path.GetDirectoryName(filename);
connection = new OdbcConnection(connectionString);
connection.Open();
command = new OdbcCommand("Select * FROM " +
Path.GetFileName(filename), connection);
reader = command.ExecuteReader();
 
S

shriop

No, there's no way to accomplish this with the odbc or ole drivers. You
can optionally use my parser that I sell, that you can actually just
pass the Stream you get back from GetResponseStream into, and not even
load the entire file into memory at once, and the parsing will go
nicely faster. http://www.csvreader.com

Bruce Dunwiddie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top