title: Open FoxPro Table in VB.net 2005
body: <p>I need to open foxpro free tables in vb.net using the oledb connection.</p>
  
  <p>But... I only need to get the column names. I don't really need to 'select' anything.
  I am trying to dynamically browse through all our free tables and set up a listing of every column from every file and xref that to another free table that contains a description of each column.  </p>
  
  <p>I have a working model now, but it requires that I do...</p>
  
  <pre><code>SELECT TOP 1 FROM "File" ORDER BY 1
  </code></pre>
  
  <p>But on the largest table, it takes over two minutes just to read in the first record and there are over 250 tables.  Overall, it takes between 15 and 20 minutes.</p>
  
  <p>Or, is there another way to only get the first record of the table without using 'ORDER BY'?</p>
  
  <p>Here's what I have so far.  "File" is passed in as a parameter.<br>
  It would contain info like "C:\data\table1.dbf"</p>
  
  <pre><code>Dim filePath As String
  filePath = IO.Path.GetDirectoryName(file)
  myOledbConnection = New OleDbConnection("Provider=VFPOLEDB.1;Data Source=" &amp; filePath &amp; ";Collating Sequence=MACHINE")
  myOledbCommand = New OleDbCommand
  myOledbDataAdapter = New OleDbDataAdapter
  Dim fields, from, order As String
  
  fields = "select top 1 *"
  from = " from " &amp; file
  order = " order by 1"
  
  myOledbCommand.CommandText = fields &amp; from &amp; order
  myOledbCommand.Connection = myOledbConnection
  
  myOledbDataAdapter.SelectCommand = myOledbCommand
  myOledbDataAdapter.Fill(dt)                     
  </code></pre>
  
  <p>I then take the datatable (dt) and loop through to get the column information.</p>
  
  <p>I would like it to be as quick as Visual Studio is when I create a dataset and load all tables from the directory through the wizard.  It is able to very quickly find all the column information without reading in the data from the table.</p>
  
  <p>Let me know if you need more information.</p>
  
  <p>Thanks.</p>