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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:54:20+00:00 2026-05-12T22:54:20+00:00

This is my first attempt to read an Excel 2007 file via ADO.net, and

  • 0

This is my first attempt to read an Excel 2007 file via ADO.net, and I must be missing something b/c when I try to run the query, I get an exception. When I started looking, it’s b/c the table (worksheet) isn’t there. Can someone please tell me what I’m doing wrong?

Here is my code:

        string cs = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=My File.xlsx;Extended Properties=""Excel 12.0;IMEX=1;""";

        using (OleDbConnection con = new OleDbConnection(cs))
        {

            con.Open();

            string query = "SELECT * FROM [Sheet1$]";

            OleDbCommand cmd = new OleDbCommand(query, con); 

            OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);

            DataTable dt = new DataTable();

            DataTable worksheets = con.GetSchema("Tables");


            adapter.Fill(dt);
            .
            .
            .
         }
  • 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-05-12T22:54:20+00:00Added an answer on May 12, 2026 at 10:54 pm

    Take a look at the accepted answer here

    The First Column of the excel file to put in string variable C#?

    It works for Excel 2003 but I think it could easily be adapted to work with 2007.

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

Sidebar

Related Questions

This is my first attempt at doing roles for asp.net, what I have is
I have to read a binary file in python. This is first written by
This is my first attempt at C++, following an example to calculate a tip
This is my first attempt at using Github's shared collaboration model to work on
this is my first attempt at Stack overflow, so hopefully you all can help
this if my first attempt at using streaming for WCF, and I am struggling
This is my first attempt to create a GUI in MATLAB. I haven't been
this is my first attempt at a responsive design so excuse me if this
Because this is my first attempt at an extension method that seems quite useful
This is pretty strange (admitedly, this is my first attempt with python / sqlite),

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.