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 8484369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:21:45+00:00 2026-06-10T20:21:45+00:00

I have developed a web application, which runs good when executed from Visual studio.

  • 0

I have developed a web application, which runs good when executed from Visual studio.

The theme of the application is to get the content in the excel file and display it.

We had a file upload control in our application, to get the excel file.

It works like charm when executed from the VS and i could see the desired result, but it is giving error when browsed through IIS.

Code is developed in Framework 4.0

The excel file is not uploading, and throws an error that error occured while reading the file.

Here is my code ..

Can you detect what goes wrong when browsed through IIS ?

 DataSet dsRates = new Schemas.Rates();
        DataTable dtExcel = new DataTable();
        dtDBTable = dsRates.Tables[0];
        DataTable dtColumnNameNotFound = new DataTable();

        FileStream stream;
        string changed = string.Empty;
        string FilePath = string.Empty;

        try
        {
            if (ValidateUserInputs())
            {
                DataSet dsExcel = new DataSet();
                OleDbConnection con = new OleDbConnection();
                try
                {
                    if (fupExtract.HasFile == true)
                    {
                        FilePath = Server.MapPath("~/Temp/" + fupExtract.PostedFile.FileName);

                        fupExtract.SaveAs(FilePath);


                    }
                    else
                    {
                        fupExtract = ((FileUpload)Session["FileUploadCtrl"]);
                        FilePath = Server.MapPath("~/Temp/" + fupExtract.PostedFile.FileName);
                        fupExtract.SaveAs(FilePath);

                    }


                    //Read the Excel Data in to Datatable
                    string _ConnectionString = string.Empty;
                    string _Extension = Path.GetExtension(FilePath);
                    if (_Extension.Equals(".xls", StringComparison.CurrentCultureIgnoreCase))
                    {
                        _ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + FilePath + ";Extended Properties=" + (char)34 + "Excel 8.0;HDR=NO;IMEX=1;" + (char)34;

                    }
                    //Use ACE OleDb     
                    else if (_Extension.Equals(".xlsx", StringComparison.CurrentCultureIgnoreCase))
                    {

                        _ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + FilePath + ";Extended Properties=" + (char)34 + "Excel 8.0;HDR=NO;IMEX=1;" + (char)34;


                    }
                    else
                    {
                        lblMessage.Text = fupExtract.FileName + "is not a supported format, only '.xls|.xlsx' files are supported";

                        return;
                    }
                    int i = 0;

                    con = new OleDbConnection(_ConnectionString);
                    con.ResetState();
                    con.Open();

                    DataTable dt = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
                    foreach (DataRow Sheet in dt.Rows)
                    {
                        OleDbDataAdapter daExcel = new OleDbDataAdapter("SELECT * FROM [" + Sheet["TABLE_NAME"].ToString().Trim() + "]", con);

                        DataTable dtData = new DataTable();
                        daExcel.Fill(dtData);
                        var filteredRows = dtData.Rows.Cast<DataRow>().Where(row => row.ItemArray.Any(field => !(field is System.DBNull)));
                        if (filteredRows.Count() > 0)
                        {
                            dsExcel.Tables.Add(dtData);
                        }
                        i++;
                    }
                    con.Close();
                }
                catch (Exception ex)
                {
                    lblMessage.Text = "Error occured while reading the file";

                    con.Close();
                }
        finally
                {
                    if (File.Exists(FilePath))
                    {
                        File.Delete(FilePath);
                    }


                }

Please help

Thanks,

  • 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-10T20:21:47+00:00Added an answer on June 10, 2026 at 8:21 pm

    I’ve got the answer to my question.

    It’s that I haven’t installed Office 64-bit and Microsoft.ACE.OLEDB.12.0. The one I’m using is 32-bit.

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

Sidebar

Related Questions

I want to deploy(ClickOnce Deployment) my web application which is developed in visual studio
I have developed a web application in visual studio 2010 and am attempting to
I have developed a Delphi web server application (TWebModule). It runs as a ISAPI
We have developed a web application which consumes a web service. The user will
We have a web application which has been developed over the past 7 months.
I have developed a Web application (HTML5/browser based) for a client which requires fairly
I have an already developed web application based on struts 1.2 which contains jsp
Have developed an MVC3 application which monitors when users access static content on the
I have developed a web application, in which there's a functionality to enter note
I have developed a web application which contains 50 pages & now i want

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.