C# read Excel file using OleDb , and get the exception Could not find installabl

极品老土豆 2015-12-24 04:49:13

ExcelConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Scource='C:\Users\xxglding\Desktop\数据接收模板.xlsx';Extended Properties='Excel 12.0'";
DataTable table;
using (OleDbConnection OleDbConn = new OleDbConnection(ExcelConnectionString))
{
Console.Write("Coming");
string CommandText = "select * from [sheet1$]";
OleDbCommand OleDbComm = new OleDbCommand(CommandText, OleDbConn);
OleDbDataAdapter OleDbAdapter = new OleDbDataAdapter(OleDbComm);
DataSet ds = new DataSet();
OleDbConn.Open();
OleDbAdapter.Fill(ds, "Shot");
table = ds.Tables["Shot"];
}

关于 ExcelConnectionString 的标点符号,各种形式都试过,没有用,求解
...全文
128 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
江南小鱼 2015-12-25
  • 打赏
  • 举报
回复
引用 1 楼 DBAXMMDS 的回复:
我知道了阿斯顿飞阿斯顿飞阿萨德
多动手调试,要学会自己找问题嘛,撸主
秋的红果实 2015-12-24
  • 打赏
  • 举报
回复
//OleDbCommand OleDbComm = new OleDbCommand(CommandText, OleDbConn); 去掉这句 OleDbDataAdapter OleDbAdapter = new OleDbDataAdapter(CommandText, OleDbConn); DataSet ds = new DataSet(); OleDbConn.Open(); OleDbAdapter.Fill(ds, "Sheet1"); table = ds.Tables[0];
极品老土豆 2015-12-24
  • 打赏
  • 举报
回复
我知道了阿斯顿飞阿斯顿飞阿萨德

110,539

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧