Home
Options

LINQPad connect to excel 2010 file doesn't work

edited August 2012
Hi Joe,

My computer is windows 7 64 bit and my excel is 32bit.

I tried this in LinqPad doesn't work.

string fileName = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @\Adress.xlsx;
string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileName + @;Extended Properties="Excel 12.0 Xml;HDR=YES""";
OleDbDataAdapter dataAdapter = new OleDbDataAdapter("Select * from [Sheet1$]", connectionString );
DataSet dataSet = new DataSet();
dataAdapter.Fill( dataSet );
var query = from r in dataSet.Tables[0].AsEnumerable()
select new
{
Address = r.Field("Address")
};

I have tried to download data connection components from these places and none of them work:
http://www.microsoft.com/en-us/download/details.aspx?id=23734
and
http://www.microsoft.com/en-us/download/details.aspx?id=13255

some peole suggest to run in visual studio, but I want to run under linqpad. My version is 4.42.06(Any CPU).

HOw do I solve the problem?
Sign In or Register to comment.