I have Excel 2007 and Visual Web Developer Express 2010. I would like to import Sheet1 of an xlsx file the reader then add the data to a dataset and placing that data in a MS SQL database.
string ExcelConStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcel2007file.xlsx;Extended Properties="Excel 12.0 Xml;HDR=YES"; string SQLConStr = "got connection string that works"; OleDbConnection ExcelConnection = new OleDbConnection(ExcelConStr); using (ExcelConnection) { string sql = string.Format("Select * FROM [{0}]", "Sheet1$"); OleDbCommand command = new OleDbCommand(sql, ExcelConnection); ExcelConnection.Open(); using (OleDbDataReader dr = command.ExecuteReader()) { using (SqlBulkCopy bulkCopy = new SqlBulkCopy(SQLConStr)) { bulkCopy.DestinationTableName = "dbo.databaseName"; bulkCopy.WriteToServer(dr); } } } I need something like bulkcopy that is free and easy to use if someone may make a recommendation.