asp.net – System.Data.OleDb.OleDbException:找不到可安装的ISAM
发布时间:2020-05-23 22:42:25 所属栏目:asp.Net 来源:互联网
导读:我在网上搜索过,发现很多人都在问这个问题,但没有人能解决我的问题. 我有一个Connection类,以及一个在页面中使用该类的方法. DataConn.cs public static OleDbConnection ConnectExcel(){ //Store the connection details as a string string connstr =
|
我在网上搜索过,发现很多人都在问这个问题,但没有人能解决我的问题. 我有一个Connection类,以及一个在页面中使用该类的方法. DataConn.cs public static OleDbConnection ConnectExcel()
{
//Store the connection details as a string
string connstr =
String.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=pricelist.xlsx;Extended Properties=Excel 12.0 Xml;HDR=YES");
//Initialise the connection to the server using the connection string.
OleDbConnection oledbConn = new OleDbConnection(connstr);
//Open the connection,we do this here so we can instantly be able to use SQL commands in the code.
oledbConn.Open();
return oledbConn;
}
public static void DisconnectExcel()
{
_oledbConn.Dispose();
_oledbConn.Close();
}
以及调用它的代码 protected void Page_Load(object sender,EventArgs e)
{
// Connection String
const string xlStr = "SELECT * FROM [Sheet2$]";
// Create OleDbCommand object and select data from worksheet Food
OleDbCommand cmd = new OleDbCommand(xlStr,DataConn.ConnectExcel());
// Create new OleDbDataAdapter
OleDbDataAdapter oleda = new OleDbDataAdapter();
oleda.SelectCommand = cmd;
// Create a DataSet which will hold the data extracted from the worksheet.
DataSet ds = new DataSet();
// Fill the DataSet from the data extracted from the worksheet.
oleda.Fill(ds);
// Bind the data to the GridView
gridPricelist.DataSource = ds;
gridPricelist.DataBind();
}
是的我仍然得到:
有人可以帮忙吗? 解决方法如果使用多于1个扩展属性,则必须引用值标记,否则驱动程序无法将它们与连接字符串中的其他非扩展属性区分开来;...Extended Properties=""Excel 8.0;IMEX=1""" 修改你的连接字符串 String.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=pricelist.xlsx;Extended Properties=""Excel 12.0 Xml;HDR=YES"""); 参考: (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc – asp.net MVC antiorgerytoken异常RedirectT
- asp.net-mvc – ASP.NET MVC WebSite中的ERR_EMPTY_RESPONS
- 使用ASP.NET通过POST接收(和发送)XML
- asp.net – @RenderSection在嵌套剃刀模板
- ASP.NET MVC – 如何抛出与StackOverflow类似的404页面
- asp.net-mvc-3 – 如何挂钩错误的jQuery验证不引人注目的MV
- asp.net – ASP核心:如何设置httpContext.User?
- asp.net – 从承载令牌(Web API)获取自定义声明值
- ASP.NET MVC全局授权过滤器强制登录AllowAnonymous操作
- asp.net-mvc – 从ASP.NET MVC中的部分视图中删除逻辑
推荐文章
站长推荐
- asp.net – 从MVC视图中的模型访问displayName属
- asp.net-mvc-3 – 在同一视图中更新多个项目
- asp.net – 更改后没有应用CSS
- 使用asp.net mvc进行基于REST的端点
- asp.net-web-api – 与web api和web api 2之间的
- Block内的ASP.NET服务器端注释
- asp.net-mvc – MVC与WebForms
- asp.net-mvc – ASP.NET MVC – AntiForgeryToke
- asp.net – 尽管设置了FormsAuthenticationTicke
- asp.net-mvc – 在MVC中将值从Controller传输到S
热点阅读
