【发布时间】:2012-09-21 00:39:56
【问题描述】:
我在尝试读取服务器中的 Excel 文件时遇到以下错误。
“System.AccessViolationException:试图读取或写入受保护的内存。这通常表明其他内存已损坏。”
代码在 localhost 中运行流畅,但在线托管时出现错误。
我无法发布堆栈跟踪,因为我不会每次都出错,但执行会在 "objConn.open" 行停止。页面只是说正在加载......但没有任何反应。
这是我的代码块:
fuGroupAttributes.SaveAs(IO.Path.Combine(Server.MapPath("~/Admin/SpecificationExcels"), lblParentId.Text.Trim & IO.Path.GetExtension(fuGroupAttributes.FileName)))
'saving the excel file from the fileUploader
Dim path As String = Server.MapPath("~/Admin/SpecificationExcels/" & lblParentId.Text.Trim & IO.Path.GetExtension(fuGroupAttributes.FileName))
'getting the file path from the server
Dim connectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & path & ";Extended Properties=Excel 12.0;"
Dim objConn As New OleDbConnection(connectionString)
**objConn.Open()** 'this is where i am getting the error.
Dim strConString As String = "SELECT * FROM [Sheet1$]"
编辑:页面一直说加载...它不会停止加载...
【问题讨论】: