Click here to Skip to main content
Licence CPOL
First Posted 21 Dec 2007
Views 10,960
Downloads 0
Bookmarked 13 times

How to connect Excel DB using C# .Net

By | 21 Dec 2007 | Article
Connect the Excel Tables using C# .net
Screenshot - XLSDB

Introduction

Get data from MS-Excel Using C# .Net

Using the code

Using this code you can get the data from MS-Excel. Its just a OLEDB connection as Follows
string Con_Str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + DB_Path + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\";";
                
        

in this DB_Path is the location of the .XLS file.

"HDR=Yes;" indicates that the first row contains columnnames, not data.

"HDR=No;" indicates the opposite.

"IMEX=1;" tells the driver to always read "intermixed" (numbers, dates, strings etc) data columns as text. Note that this option might affect excel sheet write access negative.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Senthil Rajan

Software Developer
Anadocs IT Solutions Pvt Ltd
India India

Member

M.Senthil Rajan,
Software Engineer,
Anadocs IT Solutions,
Chennai.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Layout  Per page   
  Refresh
GeneralBetter way PinmemberFilipKrnjic5:44 9 Jul '09  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 21 Dec 2007
Article Copyright 2007 by Senthil Rajan
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid