protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
string path = string.Concat((Server.MapPath("~/temp/" + FileUpload1.FileName)));
FileUpload1.PostedFile.SaveAs(path);
OleDbConnection oledbcon = new OleDbConnection("PROVIDER=MICROSOFT.ACE.OLEDB.12.0;DATA Source=" + path + ";Extended Properties=Excel 12.0;");
OleDbCommand cmd = new OleDbCommand("SELECT * FROM [sheet1$]", oledbcon);
OleDbDataAdapter ObjAdapter = new OleDbDataAdapter(cmd);
oledbcon.Open();
DbDataReader dr = cmd.ExecuteReader();
string con_str = @"Data Source=RANGANATH;Initial Catalog=Ndexpress;Integrated Security=True";
SqlBulkCopy bulkinsert = new SqlBulkCopy(con_str);
bulkinsert.DestinationTableName = "deliveries";
bulkinsert.WriteToServer(dr);
oledbcon.Close();
Array.ForEach(Directory.GetFiles((Server.MapPath("~/temp"))), File.Delete);
Label1.ForeColor = Color.Green;
Label1.Text = "Succssfully Added";
FetchData();
}
}
When this application run show this error-:{"The 'MICROSOFT.ACE.OLEDB.12.0' provider is not registered on the local machine."}
what is the solution?