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.