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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:13:39+00:00 2026-05-18T10:13:39+00:00

I got an error about OleDB. I just want my excel file import to

  • 0

I got an error about OleDB. I just want my excel file import to GridView.

Here is my code.

string connstr = "Provider=Microsoft.Jet.Oledb.4.0;Data Source=C:\a.xls;Extended Properties=Excel 8.0;HDR=YES;IMEX=1";

OleDbConnection conn = new OleDbConnection(connstr);

string strSQL = "Select * from [Sheet1$]";

OleDbCommand cmd = new OleDbCommand(strSQL, conn);

DataSet ds = new DataSet();

OleDbDataAdapter da = new OleDbDataAdapter(cmd);

da.Fill(ds);

GridView1.DataSource = ds;
GridView1.DataBind();

When I build project there is no error, but when I run this project, I got an error like this:

System.ArgumentException:Format of the
initialization string does not conform
to specification starting at index 47.

Line 21: string connstr =
"Provider=Microsoft.Jet.Oledb.4.0;Data
Source=C:\a.xls;Extended
Properties=Excel 8.0;HDR=YES;IMEX=1";
Line 22: Line 23:
OleDbConnection conn = new
OleDbConnection(connstr);

How can I fix this?

  • 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-18T10:13:39+00:00Added an answer on May 18, 2026 at 10:13 am

    \ is a special char in c# string literals.
    To specify paths in a string in c# either use escaping:

    string path = "C:\\myFolder\\myfile.xls";
    

    or use verbatim strings:

    string path =@"C:\myfolder\myfile.xls";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got an error today while trying to do some formatting to existing code.
I first got an error usign the code below, explaining that DataGridLinkButton' must be
I just got this error message: ... from c:/ruby/lib/ruby/gems/1.8/gems/... ... 10 levels... from c:/ruby/lib/ruby/gems/1.8/gems/...
I got this error today when trying to open a Visual Studio 2008 project
I got this error when I tried to compile an application that includes the
I got this error when trying to update an image. It was a cross-thread
We got strange error last days. ___doPostBack is undefined. We are building quite advanced
I've got an error in my build which says: Error 12 Cannot implicitly convert
I have got this error when using Enterprise Library 3.1 May 2007 version. We
Some time ago I got this error when building ANY Visual Studio Deployment project.

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.