Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8463245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:24:20+00:00 2026-06-10T14:24:20+00:00

I want to insert data from excel sheet to datatable and this was working

  • 0

I want to insert data from excel sheet to datatable and this was working fine. but i dont know why i am getting the following error now

“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 is to Retrieve Data is

 if (fupExcel.HasFile)
        {
            // Get the name of the Excel spreadsheet to upload.
            string strFileName = Server.HtmlEncode(fupExcel.FileName);
            strAct = "New Schedule is uploaded, File name:" + strFileName;

            // Get the extension of the Excel spreadsheet.
            string strExtension = Path.GetExtension(strFileName);

            // Validate the file extension.
            if (strExtension != ".xls" && strExtension != ".xlsx")
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "ntexl", "alert('Please select a Excel spreadsheet to import!');", true);
                return;
            }

            // Generate the file name to save.
            //string uploadFileName = DateTime.Now.ToString("yyyyMMddHHmmss") + strExtension;
            uploadFileName = CCMMUtility.GetCurrentDateTimeByTimeZone("US Mountain Standard Time").ToString("yyyyMMddHHmmss") + strExtension;

            // Save the Excel spreadsheet on server.
            fupExcel.UploadFile(uploadPath, uploadFileName);

            ClsScheduleFileNew objCLSSchedule = new ClsScheduleFileNew();
            ClsScheduleFileNewProp objUserFile = new ClsScheduleFileNewProp();

            objUserFile.FileName = strFileName;
            objUserFile.FilePath = uploadFileName;
            objUserFile.CreatedDate = CCMMUtility.GetCurrentDateTimeByTimeZone("US Mountain Standard Time"); //DateTime.Now;
            ScheduleFileId = objCLSSchedule.InsertFileInfo(objUserFile);
            hdfScheduleFileId.Value = ScheduleFileId.ToString();
            if (ScheduleFileId != 0)
            {
                //ViewState["nw_Upload"] = ScheduleFileId;
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "err", "alert('Some error occured while exporting the file.');", true);
                return;
            }
            // Generate the connection string for Excel file.
            strExcelConn = uploadPath;

            // There is no column name In a Excel spreadsheet. 
            // So we specify "HDR=YES" in the connection string to use 
            // the values in the first row as column names. 
            if (strExtension == ".xls")
            {
                // Excel 97-2003
                strExcelConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strExcelConn + uploadFileName + ";Extended Properties='Excel 8.0;HDR=YES;'";
            }
            else
            {
                // Excel 2007
                strExcelConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + strExcelConn + uploadFileName + ";Extended Properties='Excel 12.0 Xml;HDR=YES;'";
            }
            hdfStrExcelConn.Value = strExcelConn;
            try
            {
                ImportData(uploadFileName, uploadPath, strExcelConn, ScheduleFileId);
            }
            catch (Exception)
            {
                //Delete file over here and database entry over here.
                string path = uploadPath + uploadFileName;
                CCMMUtility.DeleteFilefromLocation(path);
                objCLSSchedule.DeleteScheduleFile(ScheduleFileId);
                ScriptManager.RegisterStartupScript(this, this.GetType(), "ntmtch", "alert('Some column values are not matched.');", true);
                return;
            }
        }

Improt function’s code is

 DataTable dt = new DataTable();
        DataRow row;
        DataTable dtExcel = CreateDataTable();

        using (OleDbConnection conn = new OleDbConnection(strConn))
        {
            OleDbDataAdapter da = new OleDbDataAdapter("select * from [Sheet1]", conn);
            da.Fill(dt);// here i am getting that error

            // Create new datatable having non empty rows
            DataTable filteredDataTable = (dt.Rows.Cast<DataRow>().Where(t => t.ItemArray.Any(field => !(field is DBNull)))).CopyToDataTable<DataRow>();

            // Fill the DataTable with data from the Excel spreadsheet.
            if (filteredDataTable.Rows.Count > 0)
            {
// my code hete to fill datatable }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T14:24:21+00:00Added an answer on June 10, 2026 at 2:24 pm

    Try using:

    "select * from [Sheet1$]"
    

    The $ is required I think.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to insert data from excel file to MySQL database using JSP. once
i want to insert data from an excel file into a local database in
i am trying to insert data from excel sheet into database in java. for
I have a php application where I want to read data from excel, Insert
I want to insert data from one DataTable to another with some conditions. I
I am working on importing data from an Excel sheet to database. The Excel
I want to insert data into a table where I don't know the next
I have some data enclosed in HTML tags. I want to insert this data
I am using an SQL query to insert data from an excel worksheet into
I have WCF Service that returns data as DataTable type. I want to insert

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.