Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
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
Updated 29-Jan-13 6:45am
v2

1 solution

Make sure the name of the sheet in Excel is actually "Sheet1$".
 
Share this answer
 
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..
Aksh@169 5-Jul-18 10:51am    
I am facing the same issue.However in my case ,I have seen that error is coming when debugging in Google Chrome.Any specific reason ?Help is appreciated

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900