我尝试从我的服务器中的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$]"编辑:页面一直在说加载...它不会停止加载...
I am getting the following error while trying to read from an excel file in my server.
"System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
The code runs smoothly in localhost, but the error comes when i host it online.
I am unable to post the stacktrace as i do not get error everytime, but the executions stops at the line "objConn.open". The page just says loading... and nothing happens.
Here is my code block :
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$]"EDIT : The page keeps saying loading ... it wont stop loading...
最满意答案
最可能的原因是,您的计算机上的用户帐户没有足够的权限来执行此操作。 在localhost上,您可能正在使用管理员帐户,而在实时计算机中则不是这样。
Most probable reason is, your user account on the machine does not have sufficient access to perform this operation. On localhost, you might be using the Administrator account and it is not so in the live machine.
更多推荐
发布评论