0

I can easily get a list of columns from an excel file like this:

columns = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, new string[] { null, null, tableName, null });

I'd like to do the same for a CSV file but I'm not sure what parameters are required. My connection string to the CSV file is:

"Provider=Microsoft.ACE.OLEDB.12.0; Data Source={0}; Extended Properties='text; FMT=Delimited(,); ReadOnly={1}; HDR={2}'".FormatString(directory, readOnly, (firstLineIsColumnHeaders ? "yes" : "no"))

Which turns out (in this case) to be something like:

Provider=Microsoft.ACE.OLEDB.12.0; Data Source=C:\Windows\Temp\sadf83.tmp; Extended Properties='text; FMT=Delimited(,); ReadOnly=true; HDR=yes'

But when I try to GetOleDbSchemaTable, the command returns okay but gives me an empty DataTable; the same is true when I try to GetSchema("Columns").

Josh M.
  • 26,437
  • 24
  • 119
  • 200
  • possible duplicate of [Get all tables and all columns from a odbc database](http://stackoverflow.com/questions/12197532/get-all-tables-and-all-columns-from-a-odbc-database) – MethodMan Apr 05 '13 at 20:25
  • @I4V Not difficult at all, but I'd rather use built-in methods than rewrite the same logic! – Josh M. Apr 05 '13 at 20:45
  • @DJKRAZE Thanks, but I've already tried both methods in that post and I still end up with an empty `DataTable`. Actually selecting data from the CSV file works fine, just the OleDb methods of getting the schema/columns does not work. – Josh M. Apr 05 '13 at 20:52

0 Answers0