我在Excel工作簿中编写了一些VBA代码,以从桌面上同一目录中的Access数据库中检索数据.它在我的机器和运行Windows XP的其他几台机器上运行良好,但是当我们在Vista机器上测试时,我们遇到以下错误:
找不到可安装的ISAM
我在网上做了很多搜索,但似乎找不到具体的答案.连接字符串似乎很好,正如我所提到的,它适用于多台机器.
有谁知道是什么原因引起的?我的连接字符串如下:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\ptdb\Program Tracking Database.mdb;
Run Code Online (Sandbox Code Playgroud)
谢谢
我在网上搜索过,发现很多人都在问这个,但没有一个人能解决我的问题.
我有一个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();
}
Run Code Online (Sandbox Code Playgroud)
以及调用它的代码
protected void Page_Load(object sender, EventArgs e)
{
// Connection …Run Code Online (Sandbox Code Playgroud) 这是我的代码,它位于将.xls文件转换为.csv的方法的开头。
sourceFile="C:\\Users\\myUser\\Desktop\\Folder\\myFile.xls";
string strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + sourceFile + ";Extended Properties=\"Excel 8.0;HDR=No;IMEX=1\"";
OleDbConnection conn = new OleDbConnection(strConn);
conn.Open();
Run Code Online (Sandbox Code Playgroud)
它在最后一行崩溃,并引发以下异常:外部数据库驱动程序(22)发生意外错误。
我尝试删除IMEX = 1部分,但仍然无法正常工作。
问题是什么?