How to connect Excel DB using C# .Net





0/5 (0 vote)
Connect the Excel Tables using C# .net
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 Followsstring 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.