Click here to Skip to main content
12,396,230 members (63,226 online)
Rate this:
 
Please Sign up or sign in to vote.
string connectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filename + ";Extended Properties='Excel 12.0 xml;HDR=YES;'";
string strSQL = "SELECT * FROM [Sheet1$]";
                OleDbConnection excelConnection = new OleDbConnection(connectionString);
excelConnection.Open();
OleDbCommand dbCommand = new OleDbCommand(strSQL, excelConnection);
                OleDbDataAdapter dataAdapter = new OleDbDataAdapter(dbCommand);
dataAdapter.Fill(dsExcelData);
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." when i run this piece of code.
What is the solution for the error?
Pls answer asap..urgent..
Posted 29-Jan-13 4:30am
Updated 29-Jan-13 6:45am
v2

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Make sure the name of the sheet in Excel is actually "Sheet1$".
  Permalink  
Comments
joeller 22-Jul-14 15:59pm
   
That is not a satisfactory answer. I am receiving the exact same error and not only do I know that the file has a "Sheet1$" but I also had in working in development before deploying to the test server.
menna___1 26-Jun-15 9:29am
   
Remove this part from the connection string to be

strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;Persist Security Info=False";
cmcmurugan 8-Apr-16 0:03am
   
this code
string connectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filename + ";Extended Properties='Excel 12.0 xml;HDR=YES;'";
string strSQL = "SELECT * FROM [Sheet1$]";
OleDbConnection excelConnection = new OleDbConnection(connectionString);
excelConnection.Open();
OleDbCommand dbCommand = new OleDbCommand(strSQL, excelConnection);
OleDbDataAdapter dataAdapter = new OleDbDataAdapter(dbCommand);
dataAdapter.Fill(dsExcelData);
and
this code
strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;Persist Security Info=False";
same error plz solution..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160721.1 | Last Updated 29 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100