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
