3

尝试从服务器中的 excel 文件中读取时出现以下错误。

“System.AccessViolationException:试图读取或写入受保护的内存。这通常表明其他内存已损坏。”

代码在本地主机中运行顺利,但是当我在线托管时出现错误。

我无法发布堆栈跟踪,因为我每次都没有收到错误,但执行停止在"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$]"

编辑:页面一直说加载...它不会停止加载...

4

1 回答 1

2

最可能的原因是,您机器上的用户帐户没有足够的权限来执行此操作。在 localhost 上,您可能正在使用管理员帐户,而在现场机器中并非如此。

于 2012-09-29T10:28:05.917 回答