Oracle's code access via OLE DB in ASP

Source: Internet
Author: User
Tags connect ole resource oracle database
oracle| access to the system environment:
1, operating system: Windows 2000
2. Database: Oracle 8i R2 (8.1.6) for NT Enterprise Edition
3, Installation path: C:\ORACLE

Access method:

1, connect into the Sql*plus
Log in as a System/manager user,
Sql> Conn System/manager

Create a new user: such as USER1/PASS1, give Connect,resource permissions.
Sql> Grant Connect,resource to User1 identified by Pass1;

Sql> Conn User1/pass1
Sql> CREATE TABLE Test (a date);


Instance name of Oracle database, in this example: ORADB
Oracle user name, in this case: User1
Oracle Host string: ORADB

In the Tnsnames.ora file

ORADB =
(DESCRIPTION =
(Address_list =
(address = (PROTOCOL = TCP) (HOST = 192.1.1.1) (PORT = 1521))
)
(Connect_data =
(service_name = oradb)
)
)


2, in the IIS default WWW directory to create test.asp, with notebook edit, enter the following code
<%
Set Conn=server.createobject ("Adodb.connection")
Dns= "PROVIDER=ORAOLEDB.ORACLE.1; Persist Security info=true; User Id=user1; Password=pass1;data source=oradb "
Conn. Open DNS

Sql= "INSERT into Test (a) VALUES (sysdate)"
Set Rs=conn.execute (SQL)

Set rs=nothing
Conn.close
Set conn=nothing
%>

<%
Set Conn=server.createobject ("Adodb.connection")
Dns= "PROVIDER=ORAOLEDB.ORACLE.1; Persist Security info=true; User Id=user1; Password=pass1;data source=oradb "
Conn. Open DNS

Sql= "Select To_char (A, ' hh24:mi:ss ') from test"
Set Rs=conn.execute (SQL)

Do as (not rs.eof)
%>
<table border=1>
<tr><td><%=rs.fields (0) .value%></font></td>
</tr>
<%
Rs.movenext
Loop

Rs.close
Set rs=nothing
Conn.close
Set conn=nothing
%>



3, open a browser window, enter the following address to view the results of the operation, you can continue to press the F5 key to refresh the display results
Http://localhost/test.asp



Summarize:
Using the above code, you can save the hassle of creating ODBC and improve efficiency.



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.