|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
odbc & stream & excel fileparsing (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(); 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 |
|||||||||||||||||||||||