標籤:
===============================
‘conn.asp
<%
Dim connstr
connstr="provider=microsoft.ACE.oledb.12.0;data source=" & server.MapPath("database/Config.mdb")
Set conn = Server.Createobject("ADODB.Connection")
conn.Open connstr
%>
===============================
show_config.asp
<!--#include file=conn.asp-->
<%
set rs=server.CreateObject("adodb.recordset") ‘(建立recordset對象)
sqlstr="select * from config" ‘---->(message為資料庫中的一個資料表,即你要顯示的資料所存放的資料表)
rs.open sqlstr,conn,1,3 ‘ ---->(表示開啟資料庫的方式)
rs.movefirst ‘---->(將指標移到第一條記錄)
while not rs.eof ‘---->(判斷指標是否到末尾)
response.write(rs("web_name")) ‘ ---->(顯示資料表message中的name欄位)
‘response.write(rs("info"))
‘Response.write("<br/>")
rs.movenext ‘---->(將指標移動到下一條記錄)
wend ‘---->(迴圈結束)
‘------------------------------------------------------
rs.close
conn.close ‘這幾句是用來關閉資料庫
set rs=nothing
set conn=nothing
‘-------------------------------------------------------
%>
asp串連acces資料庫