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

Connect the Excel Database from C# .Net

, 21 Dec 2007 CPOL
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,

Comments and Discussions

Questioncode not downloaded PinprofessionalMember 1045066525-Jun-14 20:36 
QuestionDownload don't run! Pinmemberrochasdv16-Dec-12 16:11 
GeneralAnother way to get DataSet from Excel PinmemberCikaPero20-Jul-10 0:01 
JokeUse the English for to be better grammers Pinmemberilikc0de9-Feb-08 10:39 
GeneralRe: Use the English for to be better grammers Pinmemberaprilkacau29-Aug-10 11:18 
GeneralAdditional information PinmemberMichal Blazejczyk4-Jan-08 10: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
Web03 | 2.8.141216.1 | Last Updated 21 Dec 2007
Article Copyright 2007 by Senthil Rajan
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid