Click here to Skip to main content
13,148,427 members (66,016 online)
Click here to Skip to main content
Add your own
alternative version


38 bookmarked
Posted 21 Dec 2007

Connect the Excel Database from C# .Net

, 21 Dec 2007
Rate this:
Please Sign up or sign in to vote.
It Explains how to make a connection to the Excel and how to get the data using C# .Net


It is the simple program. it explains how to connect MS-Excel Database.


Creating Table in Excel is very simple and easy. also fetch from Excel table is also very easy.

Using the code

For Connect the Excel, we have to use the normal 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\";";

Here 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,

You may also be interested in...

Comments and Discussions

GeneralNot able to download Pin
Member 1225274514-Apr-16 8:11
memberMember 1225274514-Apr-16 8:11 
Questioncode not downloaded Pin
Member 1045066525-Jun-14 19:36
professionalMember 1045066525-Jun-14 19:36 
QuestionDownload don't run! Pin
rochasdv16-Dec-12 15:11
memberrochasdv16-Dec-12 15:11 
GeneralAnother way to get DataSet from Excel Pin
CikaPero19-Jul-10 23:01
memberCikaPero19-Jul-10 23:01 
JokeUse the English for to be better grammers Pin
ilikc0de9-Feb-08 9:39
memberilikc0de9-Feb-08 9:39 
GeneralRe: Use the English for to be better grammers Pin
aprilkacau29-Aug-10 10:18
memberaprilkacau29-Aug-10 10:18 
GeneralAdditional information Pin
Michal Blazejczyk4-Jan-08 9:53
memberMichal Blazejczyk4-Jan-08 9:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    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 | Terms of Use | Mobile
Web01 | 2.8.170924.2 | Last Updated 21 Dec 2007
Article Copyright 2007 by Senthil Rajan
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid