当前位置:Gxlcms >
数据库问题 >
win10:未在本地计算机上注册“microsoft.ACE.oledb.12.0”提供程序
win10:未在本地计算机上注册“microsoft.ACE.oledb.12.0”提供程序
时间:2021-07-01 10:21:17
帮助过:255人阅读
static DataTable ReadExcelToTable(
string path)
{
try
{
string strConn;
// strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + ";Extended Properties=‘Excel 8.0;HDR=False;IMEX=1‘";
strConn =
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path +
";Extended Properties=\"Excel 8.0;HDR=YES\"";
OleDbConnection OleConn =
new OleDbConnection(strConn);
OleConn.Open();
String sql =
"SELECT * FROM [Sheet1$]";
//可是更改Sheet名称,比如sheet2,等等
OleDbDataAdapter OleDaExcel =
new OleDbDataAdapter(sql, OleConn);
DataSet OleDsExcle =
new DataSet();
OleDaExcel.Fill(OleDsExcle, "Sheet1");
OleConn.Close();
return OleDsExcle.Tables[
"Sheet1"];
}
catch (Exception err)
{
MessageBox.Show("数据绑定Excel失败!失败原因:" + err.Message,
"提示信息",
MessageBoxButtons.OK, MessageBoxIcon.Information);
return null;
}
win10:未在本地计算机上注册“microsoft.ACE.oledb.12.0”提供程序
标签:base 连接字符串 字符串 rop zh-cn set connect new asp