Microsoft.ACE.Oledb.12.0连接中未指定的错误打开以读取excel文件

时间:2015-01-20 09:53:21

标签: vb.net excel oledbconnection

我遇到了Oledb12.0连接打开的问题,在VB.NET中读取excel文件。它适用于本地运行。但是从服务器运行时有未指定的错误。读取excel文件的连接字符串如下:

Dim filePath As String = Server.MapPath("~/TempFiles/")
If Not System.IO.Directory.Exists(filePath) Then
    System.IO.Directory.CreateDirectory(filePath)
End If

filePath = String.Concat(FileUpload1.PostedFile.FileName)

Dim excelConnectionString As String = String.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=Excel 8.0", filePath)

Using connection As New OleDbConnection(excelConnectionString)
     Dim command As OleDbCommand = New OleDbCommand("Select * FROM [Sheet1$]", connection)
     connection.Open()

当我在UI中使用标签打印输出时,我收到以下消息,因为我无法调试。

message + source + stackTrace

System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions选项,对象poolGroupProviderInfo,DbConnectionPool池,DbConnection owningObject)上的System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr,OleDbConnection连接)中未指定的errorMicrosoft Access数据库引擎系统中的System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection,DbConnectionFactory connectionFactory)上的System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)中的System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection,DbConnectionPoolGroup poolGroup)。 Data.OleDb.OleDbConnection.Open()位于D:\ Data \ Documents \ My Projects \ trunk \ folder \ folder \ moduleName \ pgForm.aspx.vb中的massUpdateEmployeeParticular_pgForm.Upload():第140行 我该如何解决这个问题?

0 个答案:

没有答案