asp教程

ASP连接Oracle数据库

位置:首页 > asp教程 > asp技巧,2015-08-04
ASP连接Oracle数据库很简单,和连接SQL数据库差不多,具体请看下面的实例:  <%  set conn=server.createobjec

ASP连接Oracle数据库很简单,和连接SQL数据库差不多,具体请看下面的实例: 

    <%
  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)
  %>
  <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
  %>

TAGS:ASP连接Oracle数据库

猜你喜欢

NewHot