Paramu
Paramu

Reputation: 613

How to read excel file datas in webforms - hosted?

I have a small project in VS-2015 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;

Upvotes: 0

Views: 359

Answers (1)

Saneesh kunjunni
Saneesh kunjunni

Reputation: 548

this is because of Microsoft office(Excel) not installed on server. so you need to install microsoft office (Excel) or install Microsoft Access Database on server.

For download Microsoft Access Database go to : https://www.microsoft.com/en-US/download/details.aspx?id=13255

Upvotes: 2

Related Questions