I am getting this error "The Microsoft Access database engine could not find the object 'Sheet1$'. Make sure the object exists and that you spell its name and the path name correctly. If 'Sheet1$' is not a local object, check your network connection or contact the server administrator."
I wrote the Code as :
string path = fileuploadExcel.PostedFile.FileName;
//Create connection string to Excel work book
string excelConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;Persist Security Info=False";
//Create Connection to Excel work book
OleDbConnection excelConnection = new OleDbConnection(excelConnectionString);
//Create OleDbCommand to fetch data from Excel
OleDbCommand cmd = new OleDbCommand("Select [studentname],[mob],[course] FROM [Sheet1$] ", excelConnection);
excelConnection.Open();
OleDbDataReader dReader;
dReader = cmd.ExecuteReader();
SqlBulkCopy sqlBulk = new SqlBulkCopy(strConnection);
//Give your Destination table name
sqlBulk.DestinationTableName = "Excel_Student";
sqlBulk.WriteToServer(dReader);
excelConnection.Close();
Shubham KumarPosted Apr 19, 2015, 8:33 AM
Please verify from the file that the three is "Sheet1" present.
cmd = New OleDbCommand("Select * from [Sheet1$]", excelconnection)
see below work around
- Have you checked your file name ?
- Have you checked excel file path ?
- Have you checked your excel file SheetName ?
Microsoft has confirmed that its bug, it gives sheet name, if error is error for file or sheet
see below code snippet
http://support.microsoft.com/kb/316809