-1

I don't get where i wrong.

when i work with local machine program run successfully. but when i upload on server it will give an error like The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine

           protected void btnImport_Click(object sender, EventArgs e)
          {
      // try{
          string connectionstring = "";
          string filename = Path.GetFileName(FileUpload1.PostedFile.FileName);
        string fileextension = Path.GetExtension(FileUpload1.PostedFile.FileName);
        string filelocation = Server.MapPath("~/file/") + filename;
        FileUpload1.SaveAs(filelocation);
        if (fileextension == ".xlsx")
        {
            connectionstring = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filelocation + ";Extended Properties=\"Excel 12.0;HDR=YES;IMEX=2\"";
            OleDbConnection conn = new OleDbConnection(connectionstring);
            OleDbCommand cmd = new OleDbCommand();
            cmd.CommandType = System.Data.CommandType.Text;
            cmd.CommandText = "select * from [Sheet1$]";
            cmd.Connection = conn;
            OleDbDataAdapter oda = new OleDbDataAdapter(cmd);
            System.Data.DataTable dt = new System.Data.DataTable();
            oda.Fill(dt);
            grvExcelData.DataSource = dt;
            Session["TaskTable"] = dt;
            grvExcelData.DataBind();
        }
      // }catch(Exception ex){Response.Write(ex.Message);  }
    }

error image enter image description here

Datta
  • 819
  • 3
  • 14
  • 27

1 Answers1

0

Install the 32bit OLEDB 12.0 driver on the server, you can find it here. Alternatively, you can use something like the excellent EPPlus if you want to play around with (xml-based) excel files without installing stuff on the server.

Mia
  • 964
  • 10
  • 15