Click here to Skip to main content
15,568,681 members
Articles / Programming Languages / C#
Posted 21 Dec 2007


38 bookmarked

Connect the Excel Database from C# .Net

Rate me:
Please Sign up or sign in to vote.
2.92/5 (9 votes)
21 Dec 2007CPOL
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)

Written By
Software Developer Anadocs IT Solutions Pvt Ltd
India India
M.Senthil Rajan,
Software Engineer,
Anadocs IT Solutions,

Comments and Discussions

BugNot able to download Pin
ashwinikumarpawar7-Aug-19 21:49
ashwinikumarpawar7-Aug-19 21:49 
GeneralNot able to download Pin
Member 1225274514-Apr-16 9:11
Member 1225274514-Apr-16 9:11 
Questioncode not downloaded Pin
PSV Ramana Kumar25-Jun-14 20:36
professionalPSV Ramana Kumar25-Jun-14 20:36 
QuestionDownload don't run! Pin
David Rocha de Almeida16-Dec-12 16:11
David Rocha de Almeida16-Dec-12 16:11 
GeneralAnother way to get DataSet from Excel Pin
CikaPero20-Jul-10 0:01
CikaPero20-Jul-10 0:01 
JokeUse the English for to be better grammers Pin
ilikc0de9-Feb-08 10:39
ilikc0de9-Feb-08 10:39 
GeneralRe: Use the English for to be better grammers Pin
aprilkacau29-Aug-10 11:18
aprilkacau29-Aug-10 11:18 
GeneralAdditional information Pin
Michal Blazejczyk4-Jan-08 10:53
Michal Blazejczyk4-Jan-08 10: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.