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

Tagged as

Go to top

How to connect Excel DB using C# .Net

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

Introduction

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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

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

Comments and Discussions

 
GeneralBetter way PinmemberFilipKrnjic9-Jul-09 5: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 | Mobile
Web03 | 2.8.140926.1 | Last Updated 21 Dec 2007
Article Copyright 2007 by Senthil Rajan
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid