Thursday, April 21, 2011

Connection String for Excel and CSV using OLEDB connection

Connection string to read Excel File

Data source is the physical path of Excel file.

Provider=Microsoft.ACE.OLEDB.12.0; Data Source=C:\Temp\YourFile.xlsx; 
Extended Properties=""Excel 12.0;HDR=NO;"";
 
HDR is  option to indicate that excle file contain column header or not.
 
Command Text : Select * from [YourSheetName$]

Connection string to read CSV File 

data source is the folder that csv file stored.

Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Temp
; Extended Properties=""text;HDR=NO;FMT=Delimited;IMEX=1;"

Command Text : Select * from [YourCSVFIleName]

No comments:

Post a Comment