Last post Aug 21, 2017 02:32 PM by Paramu
Aug 19, 2017 03:00 AM|Paramu|LINK
Hi, I have a small project in VS2015 asp.net - c#, to read excel file data's. When I run it as localhost it's working fine. But after hosting to FTP, it's not working, giving error like
The Microsoft Access database engine cannot open or write to the file ''. It is already opened exclusively by another user, or you need permission to view and write its data.
My Connection String - XLSX file
//String MyExcelFile = Server.MapPath(MyInput1.PostedFile.FileName); // Not Working
//String MyExcelFile = System.IO.Path.GetFullPath(Server.MapPath(MyInput1.PostedFile.FileName)); // Not Working
String MyExcelFile = MyInput1.PostedFile.FileName; // Working good in localhost
But giving error after published to ftp...........??????
String StrConn2 = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + MyExcelFile + "; Extended Properties=\"Excel 12.0; HDR=YES; \"";
String MyExcelSheet = "[Sheet1$]";
String MySQLSelect = "select * from " + MyExcelSheet;
Thanks for the helps !
Aug 19, 2017 08:28 AM|PatriceSc|LINK
This approach won't work. You are using MyInput1.PostedFile.FileName to directly use the client side file location but it works only if the server has access to the same drive (ie localhost where you are in the very special situation where your machine is
both the browser client and the web server).
You have to read the file content from the server to then process this file (you'll find tons of existing reference about that).
Aug 21, 2017 01:44 AM|Frotcom|LINK
Yo actualmente soy voluntariado en africa y mi pregunta es que al ser de otro pais se podria accder de la misma manera que explicais en el post.
Aug 21, 2017 08:58 AM|Eric Du|LINK
According to your description, I think there are many reasons caused this issue, here are someone who meet the similar issue as you and get the solution of this issue, please check:
The Microsoft Office Access database engine cannot open or write to the file:
Also you could refer to this sample about how to read excel file in asp.net, please check:
Read and Import Excel File into DataSet or DataTable using C# and VB.Net in ASP.Net:
Aug 21, 2017 02:32 PM|Paramu|LINK
Thanks Eric, Patrice, Frotcom Thank for the helps!