locked
The Microsoft Jet database engine could not find the object RRS feed

  • Question

  • User-812314942 posted

    try to use code below to access the .xls file, got a error. "The Microsoft Jet database engine could not find the object 'DriverDistanceData'.  
       Make sure the object exists and that you spell its name and the path name correctly" I know the error from line 1. I tried a lot ways in line 1, but didn't work


    protected void BtloadData_Click(object sender, EventArgs e)
            {

               string excelConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\DriverDistanceData.xls;Extended Properties=""Excel 8.0;HDR=YES;""";

                using (OleDbConnection connection = new OleDbConnection(excelConnectionString))
                {

                    OleDbCommand command = new OleDbCommand("Select * FROM DriverDistanceData", connection);

                    connection.Open();

                    // Create DbDataReader to Data Worksheet
                    //using (DbDataReader dr = command.ExecuteReader())
                    using (DbDataReader dr = command.ExecuteReader())
                    {.....
                    }
                 }

    }
           

    Friday, February 22, 2008 2:44 PM

All replies

  • User-1361301461 posted

    Try this way it will surely work..

     string s = "provider=Microsoft.Jet.OLEDB.4.0;" + @"data source=E:\DataXL.XLS;" + "Extended Properties=Excel 8.0;";
    OleDbConnection con = new OleDbConnection(s); // connection string
    con.Open();
    OleDbDataAdapter da = new OleDbDataAdapter("select * from [Sheet1$]", con);

     //Or Use OleDbCommand
    DataSet ds = new DataSet();
    da.Fill(ds);
    DataTable dt = ds.Tables[0];
    foreach (DataRow dr in dt.Rows)
    {

    //Console.WriteLine(dr[0]);

    Response.Write(dr[0]);
    }
    If you still have problems let me know

    Thanks and regards,

    Sridhar

     
    Saturday, February 23, 2008 6:53 AM
  • User-812314942 posted

    Thanks, I used the code you gave me. I got a same error message, like "The Microsoft Jet database engine could not find the object 'Sheet1$'.  Make sure the object exists and that you spell its name and the path name correctly." is it possible IIS server problem?

    "

    Saturday, February 23, 2008 9:50 PM
  • User-1361301461 posted

                                         Try this way           

                                        OleDbDataAdapter da = new OleDbDataAdapter("select * from [Sheet1$]", con);

                                         in the above code try to replace Replace the 'Sheet1$' with your Excel worksheet name

                                        lets say you have excel sheet DataXL.xsl and it contains worksheet named "Products"

                                        then replace the above query as "("select * from [Products$]",  con);

                                       Sridhar

    Saturday, February 23, 2008 10:07 PM
  • User-812314942 posted

    The Microsoft Jet database engine could not find the object 'Products$'.  Make sure the object exists and that you spell its name and the path name correctly.

     

    same error I got,  code below. thanks

    protected void BtloadData_Click(object sender, EventArgs e)

    {

    string s = "provider=Microsoft.Jet.OLEDB.4.0;" + @"data source=C:\XSL_DrivingDistance\test.xls;" + "Extended Properties=Excel 8.0;";

    OleDbConnection con = new OleDbConnection(s); // connection string

    con.Open();

    OleDbDataAdapter da = new OleDbDataAdapter("select * from [Products$]", con);

    //Or Use OleDbCommand

    DataSet ds = new DataSet();

    da.Fill(ds);

    DataTable dt = ds.Tables[0];foreach (DataRow dr in dt.Rows)

    {

    //Console.WriteLine(dr[0]);

    Response.Write(dr[0]);

    }

     

    }

    Saturday, February 23, 2008 10:42 PM
  • User-1361301461 posted

      Replace [Products$] with your <Excel Worksheet name>

      if your excel work sheetname is category the replace as [category$]

      I worked this way it was working absolutely fine

     other wise send me your excel sheet details

    Then I will send the code

    Thanks

    Sridhar

    Saturday, February 23, 2008 11:19 PM
  • User-812314942 posted

    Thanks, I don't think the code has a problem. either my excel file or file permission problem. my excle file was created by
    excel 97-2003workbook(*.xsl) file, not Microsoft Excel 5.0/95 workbook(*.xsl). Does your file and directory has Write permission  for Internet Guest Account(IUSE_MACHINE),I don't have this,  

     

    Saturday, February 23, 2008 11:51 PM
  • User-812314942 posted

    the problem is a config problem, not code and path problem. the same code works for my home computer. not work for office computer. but I don't know how to fix it.

    Sunday, February 24, 2008 11:39 AM
  • User1076309076 posted

    I am having the same problem. My excel file is created with Excel 2003 , with fileupload control I am selecting that file from my local machine. It works for my local dev environment but not working with other server. I found out Excel 2003 was not installed in that server from where the asp.net web is running.. Do I need to install excel 2003 on that box or it is security / permission issue?

    Friday, March 27, 2009 4:55 PM
  • User-1474376986 posted

    Hi,

    I am also having same problem,i fixed it by replacing filename in connection string  with absoulte path

    then it is working for me.

    here is my code

    OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\\programs\\BulkCreationIssue\\eq_template.xls;Extended Properties=""Excel 8.0;HDR=YES;""");
            con.Open();
            OleDbDataAdapter da = new OleDbDataAdapter("select * from [Issue$]", con);
            DataSet ds = new DataSet();
            da.Fill(ds);
            GridView1.DataSource = ds;
            GridView1.DataBind();
     Thanks&Regards

    Bharath

     

     

     

    Tuesday, April 28, 2009 7:32 AM
  • User-1528640642 posted

    Hi,

       i have the admin side, where he can have the option to import order excel and have the sample excel download link,where he can download the sample excel and he can edit it and upload again.


    the issue is when he download the sample and upload it i am getting invalid format error,suppose i open that file and save as excel again its working fine.....??????????


    mycode is



    string   strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\\TrackNumber(3).xls;Extended Properties=Excel 12.0;";
           
            OleDbConnection con = new OleDbConnection(strConn);
           
            con.Open();
            OleDbDataAdapter myCommand = new OleDbDataAdapter("SELECT * FROM [TrackNumber]", con);

            DataSet myDataSet = new DataSet();
            myCommand.Fill(myDataSet);

    Tuesday, March 30, 2010 3:30 AM
  • User-333891640 posted

    I am having a similar problem.

    I think the problem is happening because the excel file might be getting uploaded through a button click event and fill method hence cannot get that file.

    I am currently working on calling a function in the click event of the file where i am defining the data adapter  method to work on the excel sheet.

     

    Not sure if this is the right method...... !!!!!!!

     

    Wednesday, October 6, 2010 3:23 AM
  • User-1648908061 posted

    Hi,

       I want read data from excel and push into data table to process row wise operation.

    can any 1 help pls.

     

    thanks in advance.

     

    cnu.. 

    Tuesday, December 28, 2010 4:39 AM
  • User435764817 posted

    I use Your code  but it also given error......... as given below I send to you my complete code you see it

    The Microsoft Jet database engine could not find the object 'Sheet1$'. Make sure the object exists and that you spell its name and the path name correctly. 

    My code:-

    //if(! Directory.Exists(MapPath(@"~/FileFolder")))

    //{
    // Directory.CreateDirectory(MapPath(@"~/FileFolder"));

    //}
    //UploadFile(FileUpload1);


    if (FileUpload1.HasFile)
    {
    try
    {
    // alter path for your project

    FileUpload1.SaveAs(Server.MapPath("~/ArrowRevolution1.xls"));
    LabelUpload.Text = "Upload File Name: " +
    FileUpload1.PostedFile.FileName + "<br>" +
    "Type: " + FileUpload1.PostedFile.ContentType +
    " File Size: " + FileUpload1.PostedFile.ContentLength +
    " kb<br>";

    }
    catch (System.NullReferenceException ex)
    {
    LabelUpload.Text = "Error: " + ex.Message;
    }
    }
    else
    {
    LabelUpload.Text = "Please select a file to upload.";
    }



    // objDataAdapter1.SelectCommand = ExcelConnection();// call to excelsheet


    string xConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Server.MapPath("ArrowRevolution1.xls") + ";" + "Extended Properties=Excel 8.0;";
    OleDbConnection objXConn = new OleDbConnection(xConnStr);
    objXConn.Open();
    // OleDbCommand objCommand = new OleDbCommand("SELECT * FROM [Sheet1$]", objXConn);
    OleDbDataAdapter objDataAdapter1 = new OleDbDataAdapter("select * from [Sheet1$]",objXConn);
    //objDataAdapter1.SelectCommand = objCommand;
    DataSet ds = new DataSet();
    objDataAdapter1.Fill(ds);

     

    Tuesday, June 14, 2011 8:41 AM