views:

28

answers:

2

hi my Dear Friends :

in have an Excel File Named (a.xlsx) in A Folder Named (ExcelFiles).

the ExcelFiles Folder Is located in the root Of my project.

so my connection string for getting excel file data is like this :

<add name="xlsx" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=aaa\ExcelFiles\a.xlsx;Extended Properties=Excel 12.0"/>

aaa = My Project Name

with this connection string every thing is ok in local , but after upload web site i have an error.

where is the problem??

is this path true -> ~/ExcelFiles/a.xlsx or not

can u fix this path 4 me....

after solving the path problem the error is like this :

 The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.

how can i do with this error?

thanks in future advance

best regards

A: 

Have a look at the following url, it has information on how to resolve this problem

http://www.microsoft.com/downloads/en/details.aspx?FamilyID=7554F536-8C28-4598-9B72-EF94E038C891&amp;displaylang=en

Nair
thanks for your answer / but that error fires from server and in local every thing is ok / your suggested program installs on local // how can i use it in that server?
LostLord
You need to install the driver in the server for it to work or look @Justin's suggestion to move to Jet
Nair
A: 

The machine you're hosting the file on doesn't have the ACE OleDB for office driver installed. I would switch to the JetOleDB driver

A Jet OleDB connection string looks like

Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties="Excel 8.0;HDR=Yes;IMEX=1";

Excel8.0 is version 2003 I believe. For 2007 you will want to use Excel12.0

So what I would so is to do a String.Format and simply pass in the location of the excel file, of course since this appears to be an asp.net application it should look something like this:

String con = String.Format( @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties="Excel 8.0;HDR=Yes;IMEX=1"", Server.MapPath(EXCEL FILE LOCATION) );

You can of course simply put the String used in the String.Format in your config file that way it isn't hard coded like I have it.

Justin
THANKS A LOT / THE DRIVER PROBLEM SOLVED / BUT WHAT ABOUT ABSOLUTE PATH IN DATA SOURCE ? (REALLY APPRECIATE FOR YOUR ANSWERS)
LostLord
I've modified my answer to show those ideas, since they're a bit longer then what can be posted here.
Justin
SORRY - THANKS A LOT
LostLord