oracle|解決|問題 ORACLE920與ASP的串連問題的解決辦法
代碼如下:
<%
on error resume next
'串連資料庫
Set OraSession = CreateObject("OracleInProcServer.XOraSession")
set oradatabase=orasession.dbopendatabase("資料庫名","使用者名稱/密碼",0)
'出錯處理
if err.number >0 then
Response.Write "<h4>asp 錯誤控制</h4>"
Response.Write "asp 錯誤來源:"&err.Source &"<br>"
Response.Write "asp 錯誤碼:"&err.number &"<br>"
Response.Write "asp 錯誤說明:"&err.Description &"<br>"
err.Clear
Response.Write "<h4>ORACLE OLE 錯誤控制</h4>"
Response.Write "ORACLE 錯誤碼"&OraSession.lastServerErr&"<br>"
Response.Write "ORACLE 錯誤說明"&OraSession.lastServerErrtext&"<br>"
closeDatabase
displayerror
Response.end
end if
'關閉資料庫
sub closeDatabase()
oradatabase.close
'set oradatabase=nothing
orasession.close
set orasession=nothing
end sub
function displayerror()
if err.number <>0 then
Response.Write "<br><br><br><p align=center fontsize=20>資料庫連接失敗,請與系統管理員聯絡!</p>"
Response.End
end if
end function
%>
解決辦法:
1、IIS要訪問ORACLE資料庫時,在OLEDB中賦於一個許可權(是ORACLE的BUG)
在ORACLE_HOME目錄下ORA92目錄的屬性裡的安全性上添加/編輯“Authenticated Users”使用者,在其“讀取及運行”許可權上先點不選,再點選擇,然後“應用”。
2、在ORACLE_HOME目錄下ORA92\network\ADMIN目錄裡有一個“sqlnet.ora”檔案,
內容如下:
# SQLNET.ORA Network Configuration File: E:\oracle\ora92\network\admin\sqlnet.ora
# Generated by Oracle configuration tools.
NAMES.DEFAULT_DOMAIN = jgc-new.local
SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (TNSNAMES, ONAMES, HOSTNAME)
將其改為:
# SQLNET.ORA Network Configuration File: E:\oracle\ora92\network\admin\sqlnet.ora
# Generated by Oracle configuration tools.
NAMES.DEFAULT_DOMAIN = jgc-new.local
# SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (TNSNAMES, ONAMES, HOSTNAME)