Quantcast
Channel: Oracle, MySQL, Sybase, Informix and other databases
Viewing all articles
Browse latest Browse all 1350

The Microsoft Access database engine could not find the object 'Sheet1$'

$
0
0

I am trying to get data from an excel sheet and it throws me that 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.

here is my code

string filename = System.IO.Path.GetFullPath(Server.MapPath("~/App_Data/country_code.xlsx"));

                OleDbConnection countryConnection = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" +
                    filename + "; Extended Properties=Excel 12.0 Xml;");

                try
                {
                    OleDbCommand com = new OleDbCommand("select * from [Sheet1$]", countryConnection);

                    countryConnection.Open();

                    OleDbDataAdapter adapter = new OleDbDataAdapter();

                    adapter.SelectCommand = com;

                    DataSet ds = new DataSet();

                    adapter.Fill(ds);
}
catch(Exception ex)
{
ViewBag.Error = ex.Message;
}

the path to the file is right

i created anther project to test the same code and it worked fine, both are on my local machine


Viewing all articles
Browse latest Browse all 1350

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>