以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%></font></td> </tr> <% rs.movenext loop rs.close set rs=nothing conn.close set conn=nothing %> |