System.ArgumentException: Keyword not supported: 'provider'

Hi ,
kindly assist.. am trying to import data from excel to sql database. am using excel 2016.
am getting the following error " "System.ArgumentException: Keyword not supported: 'provider"
this is my web.config file where the error comes from..

**below is my c # code** using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.IO; using System.Data; using System.Data.OleDb; using System.Data.SqlClient; using System.Configuration;
    public partial class WebForm1 : System.Web.UI.Page
        protected void Upload(object sender, EventArgs e)
            string excelPath = Server.MapPath("~/Files/") + Path.GetFileName(FileUpload1.PostedFile.FileName);

            string conString = string.Empty;
            string extension = Path.GetExtension(FileUpload1.PostedFile.FileName);
            switch (extension)
                case ".xls":
                    SqlConnection MyCon = new SqlConnection(ConfigurationManager.ConnectionStrings["Excel107ConString"].ConnectionString);

            conString = string.Format(conString, excelPath);
            using (OleDbConnection excel_con = new OleDbConnection(conString))

                string sheet1 = excel_con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null).Rows[0]["TABLE_NAME"].ToString();
                DataTable dtExcelData = new DataTable();

                dtExcelData.Columns.AddRange(new DataColumn[3] { new DataColumn("InvoiceNumber", typeof(string)),
            new DataColumn("AmountPaid", typeof(decimal)),
            new DataColumn("Remarks",typeof(string)) });

                using (OleDbDataAdapter oda = new OleDbDataAdapter("SELECT * FROM [" + sheet1 + "]", excel_con))

                string consString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
                using (SqlConnection con = new SqlConnection(consString))
                    using (SqlBulkCopy sqlBulkCopy = new SqlBulkCopy(con))
                        sqlBulkCopy.DestinationTableName = "smarttable";

                        sqlBulkCopy.ColumnMappings.Add("InvoiceNumber", "InvoiceNumber");
                        sqlBulkCopy.ColumnMappings.Add("AmountPaid", "AmountPaid");
                        sqlBulkCopy.ColumnMappings.Add("Remarks", "Remarks");

kindly assist

edit delete
are you sure?
asked john kanyora

0 answers

Post an answer but please log in first

Post Answer
  1. Please log in to post answer

Similar Questions

Tagsfor this question

Forumall questions