Error - when uploading excel file to server
-
Hi, i have done one application which tooks input as excel file which contains 2 columns. i took whole excel data to datatable and add two more columsn to datatable and export this data table to csv file by creating file programatically . The application is running sucessfully in my local machine. So i deployed in server. it working fine, when i logged into that server and run from there. If i run the deployed application from my local machine using http://192.168.1.110/Myapp/uploadfile.aspx. I am getting the following error. "The Microsoft Office 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" (IF i took .xlsx file) "The Microsoft Jet database engine cannot open the file ''. It is already opened exclusively by another user, or you need permission to view its data."(IF i took .xls file) can any one say, why this error is occuring? I have given all permissons to the folder in server, where i creating the csv file.
G. Satish
-
Hi, i have done one application which tooks input as excel file which contains 2 columns. i took whole excel data to datatable and add two more columsn to datatable and export this data table to csv file by creating file programatically . The application is running sucessfully in my local machine. So i deployed in server. it working fine, when i logged into that server and run from there. If i run the deployed application from my local machine using http://192.168.1.110/Myapp/uploadfile.aspx. I am getting the following error. "The Microsoft Office 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" (IF i took .xlsx file) "The Microsoft Jet database engine cannot open the file ''. It is already opened exclusively by another user, or you need permission to view its data."(IF i took .xls file) can any one say, why this error is occuring? I have given all permissons to the folder in server, where i creating the csv file.
G. Satish
check object which is doing operation on file has disposed before using it next time
-
check object which is doing operation on file has disposed before using it next time
ya, i have closed all the objects and connections related to this.
G. Satish
-
ya, i have closed all the objects and connections related to this.
G. Satish
I think you have the file open and are trying to use that. Close the file and retry. Regards
Vijay V. Yash Softech
-
I think you have the file open and are trying to use that. Close the file and retry. Regards
Vijay V. Yash Softech
My code is as follows. I am Getting error here... as "Excel Excep:The Microsoft Office 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."
public DataTable ReadingDatafromExcel()
{
DataTable dt = new DataTable();
try
{
//Reading Data from Excel file to Data Table
string FilePath = System.AppDomain.CurrentDomain.BaseDirectory.ToString();
string _filename = Path.GetFileName(FileUpload1.PostedFile.FileName);
string _attachpath = FileUpload1.PostedFile.FileName;
string _fileexten = Path.GetExtension(FileUpload1.PostedFile.FileName);string strConn = ""; if (\_fileexten == ".xls") { strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + \_attachpath + ";" + "Extended Properties=Excel 8.0;"; } else if (\_fileexten == ".xlsx") { strConn = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + \_attachpath + ";" + "Extended Properties=Excel 12.0;"; } OleDbConnection oledbconn = new OleDbConnection(strConn); oledbconn.Close(); oledbconn.Open(); //You must use the $ after the object you reference in the spreadsheet OleDbDataAdapter myCommand = new OleDbDataAdapter("SELECT \* FROM \[Sheet1$\]", oledbconn); DataSet myDataSet = new DataSet(); myCommand.Fill(myDataSet, "ExcelInfo"); dt = myDataSet.Tables\[0\]; oledbconn.Close(); myCommand.Dispose(); //Adding Columns to Data table DataColumn dcGender = new DataColumn("Gender", System.Type.GetType("System.String")); dt.Columns.Add(dcGender); DataColumn dcCulture = new DataColumn("Culture", System.Type.GetType("System.String")); dt.Columns.Add(dcCulture); } catch (Exception dataex) { Response.Write("Excel Excep:" + dataex.Message.ToString()); } return dt; }
G. Satish