How To Upload Excel File In Sql Database

  • Uploaded by: Waqar Hussain Laghari
  • 0
  • 0
  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View How To Upload Excel File In Sql Database as PDF for free.

More details

  • Words: 59
  • Pages: 1
public void BulkExceltoSQl(string Filename) { string sconExcel = @"Provider=Microsoft.ACE.OLEDB.12.0;Excel 12.0;Database=" + Filename + @";Extended Properties='HDR=Yes;'"; using (OleDbConnection connection = new OleDbConnection(sconExcel)) { OleDbCommand command = new OleDbCommand("Select DID, City, State From [Sheet1$]", connection); connection.Open(); using (OleDbDataReader dr = command.ExecuteReader()) { string sconSQl = Config.connectionString.ToString();

} }

}

using (SqlBulkCopy bulkCopy = new SqlBulkCopy(sconSQl)) { bulkCopy.DestinationTableName = "DID"; bulkCopy.WriteToServer(dr); }

Related Documents


More Documents from ""