0

I am uploading the data of an Excel file to an HTML file. It works in my computer, but when I upload the files to the server, I find the error: "The 'Microsoft.ACE.OLEDB.12.0' provider is not registered".

The control panel in the server is Plesk. I guess I have to create a ODBC connection there, and I did it. How to use it in my code? Code below:

        protected void btnUpload_Click(object sender, EventArgs e)
        {
            string path = Path.GetFileName(FileUpload1.FileName);
            path = path.Replace(" ", "");
            FileUpload1.SaveAs(Server.MapPath("~/ExcelFile/") + path);
            String ExcelPath = Server.MapPath("~/ExcelFile/") + path;
            OleDbConnection mycon = new OleDbConnection("Provider = Microsoft.ACE.OLEDB.12.0; Data Source = " + ExcelPath + "; Extended Properties=Excel 8.0; Persist Security Info = False");
            mycon.Open();
            OleDbCommand cmd = new OleDbCommand("select * from [table$]", mycon);
            OleDbDataAdapter da = new OleDbDataAdapter();
            da.SelectCommand = cmd;
            DataSet ds = new DataSet();
            da.Fill(ds);
            grd.DataSource = ds.Tables[0];
            grd.DataBind();
            mycon.Close();
            LabelBrowse.Visible = true;
            LabelBrowse.Text = "Excel file has been saved and table populated.";
            //some more stuff...
}
  • 1
    It's already answered here: https://stackoverflow.com/questions/6649363/microsoft-ace-oledb-12-0-provider-is-not-registered-on-the-local-machine That being said - why are you using ODBC which is an ancient technology to read/write Excel. OpenXML usually works for me. – JazzmanJim Feb 01 '19 at 20:07
  • The server is hosted on a hosting site, I cannot install anything there...That is the reason I guess there is something I can setup on Plesk such as a ODBC connection... – Douglas Moura Feb 01 '19 at 21:40
  • After speaking with the hoster the conclusion is that indeed it is necessary to install "Microsoft Access Database Engine Redistributable". I will have to look for another hoster. I wouldn't like to use XML files because the Excel file has macros... – Douglas Moura Feb 02 '19 at 00:14

0 Answers0