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")
.