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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:27:17+00:00 2026-06-14T06:27:17+00:00

I am doing this to read : private bool writetoven(string xlspath) { OleDbConnection excelConnection

  • 0

I am doing this to read :

private bool writetoven(string xlspath)
{
    OleDbConnection excelConnection = new OleDbConnection(excelConnectionString)


    try
    {
        OleDbCommand ocmd = new OleDbCommand("select * from [Sheet1$]", excelConnection);
        excelConnection.Open();
        OleDbDataReader odr = ocmd.ExecuteReader();
        string vcode = "";
        string pswd = "";
        string vname = "";

        while (odr.Read())
        {
            vcode = valid(odr, 0);
            pswd = valid(odr, 1);
            vname = valid(odr, 2);

            insertdataintosql(vcode,pswd,vname);
        }
        excelConnection.Close();
        return true;
    }
    catch (DataException)
    {
        return false;
    }
    finally
    {
        lblmsg4.Text = "Data Inserted Sucessfully";
    }
}

and my connection string is like this:

excelConnectionString = "provider=Microsoft.jet.oledb.4.0;data source=" + 
                        filepath1 + 
                        ";extended properties='Excel 8.0;HDR=YES;'";

but I am getting an error as

The Microsoft Jet database engine cannot open the file ”. It is already opened exclusively by another user, or you need permission to view its data.

Line 1574: OleDbConnection excelConnection = new OleDbConnection(excelConnectionString);
Line 1575:
Line 1576: excelConnection.Open();
Line 1577:
Line 1578:

It seems like the file is still open but its not and I have checked the running process and its not there

Now what should I do? …My Excel sheet is closed but I am getting this error

i dont have microsoft access on my com is that can be an issue

is this problem is something to do with my fileupload control that i am using??

  • 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-14T06:27:18+00:00Added an answer on June 14, 2026 at 6:27 am

    Make sure the account your web app is running under has permissions on the file.

    Also, since you are not using a path, and just a filename, it might not be finding the file where it is at. Where is the file located relative to your web application?

    Does System.IO.File.ReadAllBytes(filepath1) succeeed or fail?

    Since you are dealing with a file upload:

    The user is uploading from their computer through the browser, and the file is transferred to your server in the post response. See: http://blog.divergencehosting.com/2009/03/12/upload-read-parse-file-aspnet/

    Even if you had the full path, you wouldn’t be able to access the file on the user’s computer from your server. The browser sends you a copy of the file in uploadControl.PostedFile.InputStream; where uploadControl is the name of your asp:FileUpload control.

    You would then need to save this stream to a file location on the server, and provide this full path to the connection string.

    If you used something like EPPlus to read the file instead of the OleDbConnection, you could use the in-memory stream instead of saving the file first.

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

Sidebar

Related Questions

I am doing this homework where I am supposed to read a .txt file
I have this class: public class UploadFile : INotifyPropertyChanged { private string name; public
I'm just curious if I'm doing this right. I'm coding a private section of
I'm getting a null pointer exception when I do this: private String[] foo; private
Im doing this to create the file and save to it: w = new
Im doing this project where i need to download files through a webservice (images,
I am interested in doing this C code in Java: // sets n's ith
I am doing this currently, class Page { // variable to hold DBC class
I'm doing this interface where I have a lot of buttons that are just
So I am doing this query from PHP, and here listerally the exact query

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.