Click here to Skip to main content
Click here to Skip to main content

Tagged as

How to connect Excel DB using C# .Net

, 21 Dec 2007 CPOL
Rate this:
Please Sign up or sign in to vote.
Connect the Excel Tables using C# .net
Screenshot - XLSDB


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.


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
M.Senthil Rajan,
Software Engineer,
Anadocs IT Solutions,

Comments and Discussions

GeneralBetter way PinmemberFilipKrnjic9-Jul-09 6:44 

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.

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