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 to SQL * Plus
Log On As A system/Manager User,
SQL> conn system/Manager
Create a new user, such as user1/pass1, and grant connect and resource permissions.
SQL> grant connect, resource to user1 identified by pass1;
SQL> conn user1/pass1
SQL> Create Table Test (a date );
The instance name of the Oracle database, in this example: oradb
Oracle username, for example, user1
Oracle host string: oradb
Tnsnames. ora File
Oradb =
(Description =
(Address_list =
(Address = (Protocol = TCP) (host = 192.1.1.1) (Port = 1521 ))
)
(CONNECT_DATA =
(SERVICE_NAME = oradb)
)
)
2. Create test. asp in the IIS default WWW directory and use notebook to edit it. Enter the followingCode
<%
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 rsw.conn.exe cute (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 rsw.conn.exe cute (SQL)
Do While (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 and enter the following address to view the running result. You can press F5 to refresh the display result.
Http: // localhost/test. asp
Summary:
With the above code, you can save the trouble of creating ODBC and improve the efficiency.