asp不用DSN访问数据库,asp不用DSN访问数据库
【 tulaoshi.com - ASP 】
一个DSN连接需要服务器的系统管理员在服务器上用控制面板中的ODBC工具设置一个DSN,或者使用一个第三方的服务器组件,让你的ASP脚本在需要时通过修改注册表建立DSN.  <HTML<HEAD
  <TITLEnwind.asp</TITLE
  <body bgcolor="#FFFFFF"</HEAD
  <% 
  set conntemp=server.createobject("adodb.connection")
  ' 不用DSN建立连接
  DSNtemp="DRIVER={Microsoft Access Driver (*.mdb)}; "
  DSNtemp=dsntemp & "DBQ=" & server.mappath("nwind.mdb")
  conntemp.Open DSNtemp
  ' 不用DSN建立连接
  set rstemp=conntemp.execute("select * from customers where country='germany'")
  howmanyfields=rstemp.fields.count -1
  %
  <table border=1
  <tr
  <% 'Put Headings On The Table of Field Names
  for i=0 to howmanyfields %
  <td<b<%=rstemp(i).name %</B</TD
  <% next %
  </tr
  <% ' Now lets grab all the records
  do while not rstemp.eof %
  <tr
  <% for i = 0 to howmanyfields%
  <td valign=top<%=rstemp(i)%</td
  <% next %
  </tr
  <% rstemp.movenext
  loop
  rstemp.close
  set rstemp=nothing
  conntemp.close
  set conntemp=nothing %
  </table
  </BODY
  </HTML
来源:http://www.tulaoshi.com/n/20160129/1510606.html
看过《asp不用DSN访问数据库》的人还看了以下文章 更多>>