title: schema.ini to define a csv
body: <p>Apparently I'm missing something while trying to use a schema.ini to define a csv.  My code seems to ignore the schema.ini. </p>
  
  <p>The schema.ini is placed in the same subdir as the csv and is as follows:</p>
  
  <pre><code>[excel.csv]
  Format = CSVDelimited
  
  Col1=TSP text width 17
  Col2=Svc text width 17
  Col3=DTM text width 3
  </code></pre>
  
  <p>The csv data which consists of a 'heading' row and a 'data' row is as follows:</p>
  
  <pre><code>"TSP","Svc","DTM"
  
  "006958581","006927792","rdt"
  </code></pre>
  
  <p>The code I'm attempting to use is as follows:</p>
  
  <pre><code>Imports System.Data.OleDb
  Module Module1
  Sub Main()
  
  Dim Csv_in_name As String = "excel.csv"
  Dim Csv_in_path As String =
          "C:\Documents and Settings\Administrator\My Documents" + _
          "\Visual Studio 2008\Projects\csv_reader\csv_reader\bin\Debug"
  Dim cn As New OleDbConnection
  Dim adapter As New OleDbDataAdapter
  Dim cmd As New OleDbCommand
  Dim dtset As New DataSet
  Dim dt As New DataTable
  Dim cnstr As String =
          "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data source = " + _
          Csv_in_path + "\; Extended Properties=""Text;HDR=No;FMT=Delimited"""
  
  cn.ConnectionString = cnstr
  cn.Open()
  
  cmd.Connection = cn
  cmd.CommandText = "Select * from " + Csv_in_name
  
  adapter.SelectCommand = cmd
  adapter.Fill(dtset, "MyTable")
  
  dt = dtset.Tables("MyTable")
  cn.Close()
  dt.WriteXml(Csv_in_path + "\data.xml")
  
  End Sub
  End Module
  </code></pre>
  
  <p>When <code>HDR=No</code> in the connection string, the code seems to ignore schema.ini as evidenced by the field delimiter names.  Both rows are interpreted as data and the XML data is as follows:</p>
  
  <pre><code>&lt;?xml version="1.0" standalone="yes" ?&gt;
  &lt;NewDataSet&gt;
    &lt;MyTable&gt;
      &lt;F1&gt;TSP&lt;/F1&gt;
      &lt;F2&gt;Svc&lt;/F2&gt;
      &lt;F3&gt;DTM&lt;/F3&gt;
    &lt;/MyTable&gt;
    &lt;MyTable&gt;
      &lt;F1&gt;006958581&lt;/F1&gt;
      &lt;F2&gt;006927792&lt;/F2&gt;
      &lt;F3&gt;rdt&lt;/F3&gt;
    &lt;/MyTable&gt;
  &lt;/NewDataSet&gt;
  </code></pre>
  
  <p>When <code>HDR=Yes</code>, schema.ini is ignored as expected and the fields are properly labeled via the first row in the csv.  The XML data is as follows:</p>
  
  <pre><code>&lt;?xml version="1.0" standalone="yes" ?&gt;
  &lt;NewDataSet&gt;
    &lt;MyTable&gt;
      &lt;TSP&gt;006958581&lt;/TSP&gt;
      &lt;Svc&gt;006927792&lt;/Svc&gt;
      &lt;DTM&gt;rdt&lt;/DTM&gt;
    &lt;/MyTable&gt;
  &lt;/NewDataSet&gt; 
  </code></pre>
  
  <p>Since the schema.ini is present in both instances, I would have expected 2 rows of data in the first instance but with the same field delimiters as in the second instance since these are the definitions in schema.ini.  Why is schema.ini being ignored?</p>