Click here to Skip to main content
11,706,979 members (34,894 online)
Click here to Skip to main content

Connect the Excel Database from C# .Net

, 21 Dec 2007 CPOL 100.8K 1.4K 37
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

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    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.150819.1 | Last Updated 21 Dec 2007
Article Copyright 2007 by Senthil Rajan
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid