title: External table is not in the expected format error while trying to access Excel
body: <p>I am trying to access Excel from my vb application by using the Oledb Connection .
  Here is my connection string:</p>
  
  <pre><code>&lt;add key="ExcelConnection" value="Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=&amp;quot;Excel 12.0 Xml;HDR=NO;IMEX=1;MAXSCANROWS=1000;READONLY=FALSE;&amp;quot;" /&gt;
  </code></pre>
  
  <p>Here is the code:</p>
  
  <pre><code> Dim connection As New System.Data.OleDb.OleDbConnection(ExcelConnectionString)
   connection .Open()
   Dim schTbl As DataTable = connection .GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, Nothing)
  
   Dim dbAdapter As System.Data.OleDb.OleDbDataAdapter
   Dim execQuery As String
   Dim rtnData As System.Data.DataTable
  
   execQuery = "SELECT * FROM [" &amp; schTbl.Rows.Item(0)("TABLE_NAME") &amp; "]"
  
      dbAdapter = New System.Data.OleDb.OleDbDataAdapter(execQuery , ExcelConnectionString)
  
      dbAdapter.Fill(rtnDat )
  
      dbAdapter.Dispose()
      connection .Close()
      schTbl .Reset()
  </code></pre>
  
  <p>What my problem is that ,the above is working 70% of the times but rest of the times i am getting the following error:</p>
  
  <pre><code>System.Data.OleDb.OleDbException (0x80004005): External table is not in the expected format.
  </code></pre>
  
  <p>Could anyone please help me that why at times i am getting this error .Is there any way to rectify it or any other way to achive the same result.</p>
  
  <p>Any help will be appreciated.</p>
  
  <p>Thanks</p>