Thursday, 15 March 2012

vb.net - External table is not in the expected format error while trying to access Excel -


I'm trying to access Excel from my vb application using Oleb Connection. Here is my connection string:

  & lt; Add key = "ExcelConnection" value = "Provider = Microsoft.ACE.OLEDB.12.0; Data Source = {0}; Extended Properties = & amp; quot; Excel 12.0 XML; HDR = No; lmx = 1; Makssnnrows = 1000; Radonly = flesey; and & quot; "/ & gt; The  

Here's the code:

  dim connection relationship KOpen (as New System.Data.OleDb.OleDbConnection (ExcelConnectionString)) Dim schTbl DataTable as = connection .GetOleDbSchemaTable (System.Data.OleDb.OleDbSchemaGuid.Tables, nothing) Dim dbAdapter as System.Data.DataTable as string DM rtnData as System.Data.OleDb.OleDbDataAdapter Dim execQuery 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 ()  

  System.Data.OleDb.OleDbException (0x80004005): what external table My problem is that, at times, but at times I have been working over the rest of the getting the following error 70% is not in the relatively format  

Anyone can help me please this is the reason why many times I am getting this error there to get this or someone to achieve the same resultsNY ways to fix any kind of .is to.

Any help would be appreciated.

Thanks

"itemprop =" text ">

External table is not in the expected format. Usually occurs when trying to use an Excel 2007 file.

Using the following connection string seems to fix most problems.

  dim path string = yourfilepath string as dim ConnStr = "Provider = Microsoft.ACE.OLEDB.12.0; Data Source =" + path + "; Extended Properties = Excel 12.0;"  

Edit

This can happen sometime when you are using the .xlsx file If so, then you should install a JAT database engine in your PC to override those errors. This is availale


No comments:

Post a Comment