1
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();
}
}
으로하면이 응용 프로그램을 실행 공연이 오류 - :{"The 'MICROSOFT.ACE.OLEDB.12.0' provider is not registered on the local machine."}
읽기 엑셀 시트 데이터와 바인딩 ASP.NET의 GridView
해결책은 무엇인가?
이를 추가합니다. http://stackoverflow.com/questions/6649363/microsoft-ace-oledb-12-0-provider-is-not-registered-on-the-local-machine –