Solution to the connection problem between ORACLE920 and ASP

Source: Internet
Author: User
Tags error code error handling ole oracle database
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)



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.