oracle| solution to the problem of ORACLE920 and ASP connection
The code is as follows:
<%
On Error Resume Next
' Connect to the database
Set orasession = CreateObject ("Oracleinprocserver.xorasession")
Set Oradatabase=orasession.dbopendatabase ("Database name", "username/password", 0)
' Error handling
If Err.Number >0 Then
Response.Write "
Response.Write "ASP Error Source:" &err. Source & "<br>"
Response.Write "ASP Error code:" &err.number & "<br>"
Response.Write "ASP Error Description:" &err. Description & "<br>"
Err. Clear
Response.Write "
Response.Write "ORACLE error code" &OraSession.lastServerErr& "<br>"
Response.Write "ORACLE Error description" &OraSession.lastServerErrtext& "<br>"
CloseDatabase
DisplayError
Response.End
End If
' Close the database
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> database connection failed, please contact your system administrator!" </p> "
Response.End
End If
End Function
%>
Solution:
1. When IIS accesses an Oracle database, it assigns a permission in OLE DB (a bug for Oracle)
Add/Edit the "Authenticated Users" user in the ORA92 directory's properties under the Oracle_home directory, click on the "Read and run" permission first, then click Select, then "Apply".
2, in the Oracle_home directory ora92\network\admin directory has a "Sqlnet.ora" file,
The contents are as follows:
# 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)
Change it to read:
# 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)