1. 程式人生 > >[SQL] - Attempted to read or write protected memory. This is often an indication that other memory is corrupt. 問題之解決

[SQL] - Attempted to read or write protected memory. This is often an indication that other memory is corrupt. 問題之解決

img png .com 異常 hresult image select att blog

場景:

使用 Oracle.DataAccess.dll 訪問數據庫時,OracleDataAdapter 執行失敗。

技術分享

異常:

System.AccessViolationException was unhandled
HResult=-2147467261
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source=Oracle.DataAccess

技術分享

分析:

有問題的SQL
select distinct username from user u, role r where u.roleid = r.id and u.id = 1

正確的SQL
select distinct u.username from user u, role r where u.roleid = r.id and u.id = 1

總結:

規範使用 SQL 語法,指定表別名進行聯合查詢。

[SQL] - Attempted to read or write protected memory. This is often an indication that other memory is corrupt. 問題之解決