系统环境
操作系统Windows
数据库Oracle i R () for NT 企业版
安装路径C:\ORACLE
访问方法
连入SQL*Plus
以system/manager用户登录
SQL> conn system/manager
创建新的用户如user/pass赋予connectresource权限
SQL> grant connectresource to user identified by pass;
SQL> conn user/pass
SQL> create table test(a date);
Oracle数据库的实例名本例oradb
Oracle用户名本例user
Oracle主机字符串oradb
tnsnamesora文件中
ORADB =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = )(PORT = ))
)
(CONNECT_DATA =
(SERVICE_NAME = oradb)
)
)
在IIS默认WWW目录下创建testasp用notebook编辑输入以下代码
<%
set conn=servercreateobject(nnection)
dns=Provider=OraOLEDBOracle;Persist Security Info=True;User ID=user;Password=pass;Data Source=oradb
connOpen dns
SQL=insert into test(a) values(sysdate)
set rs=connexecute(SQL)
set rs=nothing
connclose
set conn=nothing
%>
<%
set conn=servercreateobject(nnection)
dns=Provider=OraOLEDBOracle;Persist Security Info=True;User ID=user;Password=pass;Data Source=oradb
connOpen dns
SQL=select to_char(ahh:mi:ss) from test
set rs=connexecute(SQL)
do while (not rseof)
%>
<table border=>
<tr><td><%=rsfields()value%></font></td>
</tr>
<%
rsmovenext
loop
rsclose
set rs=nothing
connclose
set conn=nothing
%>
打开一个浏览器窗口输入以下地址来查看运行结果可以通过不断的按F键来刷新显示结果
总结
利用以上代码可以省去创建ODBC的麻烦并提高效率