For one of the project I make, I need to retrieve list from Sharepoint using OleDB. Below you can see the code I use:
string ConnectionString = "WSS;HDR=YES;IMEX=2;DATABASE=XXX;LIST=YYY;RetrieveIds=Yes;TABLE=ZZZ;Provider=Microsoft.ACE.OLEDB.12.0";
string query = "Select * From [Table]";
OLEDBConnection conn = new OLEDBConnection(ConnectionString);
conn.Open();
OLEDBDataAdapter dataAdapter = new OLEDBDataAdapter(query, conn);
DataSet ds = new DataSet();
dataAdapter.Fill(ds);
In place of xxx, yyy, zzz I insert values obtained from .iqy file generated from Sharepoint.
Computer is runnning on Windows 10 Enterprise x64 and have pre-installed Office Professional 2016 x86 (please note that, there is no posibilty of installing 64 bit Office) including Access 2016. Sharepoint server is Sharepoint 2013 version.
With this setup the code threw an exception Invalid argument
upon opening connection. I've also made sure that 12.0 provider was registered. Trying to change the provider to 16.0 version did result in exactly same exception.
I was advised to try it with "Microsoft Access Database Engine 2010" (x86).
After installation of that engine from Microsoft page code above started to work. I was able to make connection and get the list using query.
However, after opening Access, before it opens, it runs some repairs (Office Professional installation is triggered). After this repair the code again stops to work until I reinstall the "Microsoft Access Database Engine 2010"
I've tried to use parameters from Access Linked Table connection string. (It is using ACEWSS; parameter instead of WSS;), but without any result.
I tried also to remove WSS parameter from connection string but then code throws an error Could not find installable ISAM
.
Below please find all connection strings used for connection with the result:
Default Access Engine (from Office):
WSS;HDR=YES;IMEX=2;DATABASE=XXX;LIST=YYY;RetrieveIds=Yes;TABLE=ZZZ;Provider=Microsoft.ACE.OLEDB.12.0"
- Invalid Argument
ACEWSS;HDR=YES;IMEX=2;DATABASE=XXX;LIST=YYY;RetrieveIds=Yes;TABLE=ZZZ;Provider=Microsoft.ACE.OLEDB.12.0"
- Invalid Argument
HDR=YES;IMEX=2;DATABASE=XXX;LIST=YYY;RetrieveIds=Yes;TABLE=ZZZ;Provider=Microsoft.ACE.OLEDB.12.0"
- Could not find installable ISAMWSS;HDR=YES;IMEX=2;DATABASE=XXX;LIST=YYY;RetrieveIds=Yes;TABLE=ZZZ;Provider=Microsoft.ACE.OLEDB.16.0"
- Invalid Argument
WSS;HDR=YES;IMEX=2;DATABASE=XXX;LIST=YYY;RetrieveIds=Yes;TABLE=ZZZ;Provider=Microsoft.ACE.OLEDB.16.0"
- Invalid Argument
HDR=YES;IMEX=2;DATABASE=XXX;LIST=YYY;RetrieveIds=Yes;TABLE=ZZZ;Provider=Microsoft.ACE.OLEDB.16.0"
- Could not find installable ISAMAccess Database Engine 2010 Installed:
WSS;HDR=YES;IMEX=2;DATABASE=XXX;LIST=YYY;RetrieveIds=Yes;TABLE=ZZZ;Provider=Microsoft.ACE.OLEDB.12.0"
- This one works fine!ACEWSS;HDR=YES;IMEX=2;DATABASE=XXX;LIST=YYY;RetrieveIds=Yes;TABLE=ZZZ;Provider=Microsoft.ACE.OLEDB.12.0"
- The Microsoft Access database engine could not find the object 'Table'.
HDR=YES;IMEX=2;DATABASE=XXX;LIST=YYY;RetrieveIds=Yes;TABLE=ZZZ;Provider=Microsoft.ACE.OLEDB.12.0"
- Could not find installable ISAMWSS;HDR=YES;IMEX=2;DATABASE=XXX;LIST=YYY;RetrieveIds=Yes;TABLE=ZZZ;Provider=Microsoft.ACE.OLEDB.16.0"
- Application stops working.
ACEWSS;HDR=YES;IMEX=2;DATABASE=XXX;LIST=YYY;RetrieveIds=Yes;TABLE=ZZZ;Provider=Microsoft.ACE.OLEDB.16.0"
- Application stops working.HDR=YES;IMEX=2;DATABASE=XXX;LIST=YYY;RetrieveIds=Yes;TABLE=ZZZ;Provider=Microsoft.ACE.OLEDB.16.0"
- Could not find installable ISAM
I've run out of ideas, how to get this connection established and working on the default drivers used by Access and neither understand why the same connection string works with the 2010 version installed and does not work with the default Access 2016 driver. I will appreciate any advice.