最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
ASP 中通过OLEDB访问 Oracle 的代码
时间:2022-06-30 10:24:24 编辑:袖梨 来源:一聚教程网
系统环境:
1、操作系统:Windows 2000
2、数据库: Oracle 8i R2 (8.1.6) for NT 企业版
3、安装路径:C:ORACLE
访问方法:
1、连入SQL*Plus
以system/manager用户登录,
SQL> conn system/manager
创建新的用户:如user1/pass1,赋予connect,resource权限。
SQL> grant connect,resource to user1 identified by pass1;
SQL> conn user1/pass1
SQL> create table test(a date);
Oracle数据库的实例名,本例:oradb
Oracle用户名,本例:user1
Oracle主机字符串:oradb
tnsnames.ora文件中
ORADB =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.1.1.1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = oradb)
)
)
2、在IIS默认WWW目录下创建test.asp,用notebook编辑,输入以下代码
<%
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 while (not rs.eof)
%>
1、操作系统:Windows 2000
2、数据库: Oracle 8i R2 (8.1.6) for NT 企业版
3、安装路径:C:ORACLE
访问方法:
1、连入SQL*Plus
以system/manager用户登录,
SQL> conn system/manager
创建新的用户:如user1/pass1,赋予connect,resource权限。
SQL> grant connect,resource to user1 identified by pass1;
SQL> conn user1/pass1
SQL> create table test(a date);
Oracle数据库的实例名,本例:oradb
Oracle用户名,本例:user1
Oracle主机字符串:oradb
tnsnames.ora文件中
ORADB =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.1.1.1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = oradb)
)
)
2、在IIS默认WWW目录下创建test.asp,用notebook编辑,输入以下代码
<%
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 while (not rs.eof)
%>
<%=rs.fields(0).value%> |