Home > ASP.Net, Misc, MOSS 2007, SharePoint, SharePoint 2010, SharePoint 2013, WSS 3.0 > OleDBConnection – Unspecified error

OleDBConnection – Unspecified error

On top of SharePoint 2010, I was trying to create an excel parser where I hit with this strange “Unspecified error”. The exception is getting generated from “OleDBConnection.Open” method

There was no inner exceptions or stack traces, which made it difficult to find the root cause. After trying out different steps like uninstalling office, restarting iis etc. eventually I resolved it by the below 3 steps

  1. Download latest Access Databas Engine http://www.microsoft.com/en-in/download/details.aspx?id=13255. Ensure to select the correct platform 32 vs 64
  2. Connection string = “Provider=Microsoft.ACE.OLEDB.12.0;Data Source=fileLocation;Extended Properties=”Excel 12.0 Xml;HDR=Yes;IMEX=1”
  3. In the web configuration file turn off Impersonation¬†<identity impersonate=”false” />

In the connection string I am using HDR=Yes, this mean the first row in the excel file is a header row. IMEX=1 will force the excel cells to be treated as Text rather than the Excel General type which converts the data (The feature I hate most)

  1. John
    February 4, 2015 at 1:37 AM

    I was having this exact same issue and kept beating my head against a wall trying to find a solution until I found this article, so thank you! The impersonation issue in particular is where I was stuck. What threw me off was that a couple accounts worked during the test while others didn’t, and the key difference was that the accounts that worked were members of the local “Administrators” group in Windows Server 2008 R2.

    There is an alternative to updating the web.config file, which worked for me. I wrapped my call to the OleDb provider with the delegate below, which overrides the impersonation setting and runs the code under the identity of the application pool.

    // implement code here

    More info on RunWithElevatedPrivileges

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: